Java Code Examples for com.nineoldandroids.animation.AnimatorSet#addListener()

The following examples show how to use com.nineoldandroids.animation.AnimatorSet#addListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResideMenu.java    From GifAssistant with Apache License 2.0 6 votes vote down vote up
/**
 * show the reside menu;
 */
public void openMenu(int direction){
    if (isInDisableDirection(direction))
        throw new IllegalArgumentException("You have set this direction disable, " +
                "but now you want to open menu in this direction.");
    setScaleDirection(direction);

    isOpened = true;
    AnimatorSet scaleDown_activity = buildScaleDownAnimation(viewActivity, 0.5f, 0.5f);
    AnimatorSet scaleDown_shadow = buildScaleDownAnimation(imageViewShadow,
            0.5f + shadowAdjustScaleX, 0.5f + shadowAdjustScaleY);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 1.0f);
    scaleDown_shadow.addListener(animationListener);
    scaleDown_activity.playTogether(scaleDown_shadow);
    scaleDown_activity.playTogether(alpha_menu);
    scaleDown_activity.start();
}
 
Example 2
Source File: BlurLayout.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private void startBlurImageDisappearAnimator(){
    if(!enableBlurBackground || mBlurImage == null)    return;

    AnimatorSet set = new AnimatorSet();
    if(enableBackgroundZoom)
        set.playTogether(
                ObjectAnimator.ofFloat(mBlurImage, "alpha", 1f, 0.8f),
                ObjectAnimator.ofFloat(mBlurImage, "scaleX", mZoomRatio, 1f),
                ObjectAnimator.ofFloat(mBlurImage, "scaleY", mZoomRatio, 1f)
        );
    else
        set.playTogether(
                ObjectAnimator.ofFloat(mBlurImage, "alpha", 1f, 0f)
        );

    set.addListener(mGlobalListener);
    set.addListener(mGlobalDisappearAnimators);
    set.setDuration(mBlurDuration);
    set.start();
}
 
Example 3
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * close the reslide menu;
 */
public void closeMenu() {

	isOpened = false;
	AnimatorSet scaleUp_activity = buildScaleUpAnimation(viewActivity,
			1.0f, 1.0f);
	AnimatorSet scaleUp_shadow = buildScaleUpAnimation(imageViewShadow,
			1.0f, 1.0f);
	// AnimatorSet scaleUp_activity = buildMoveLeftAnimation(viewActivity,
	// 0.0f);
	// AnimatorSet scaleUp_shadow = buildMoveLeftAnimation(imageViewShadow,
	// 0.0f);
	AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 0.0f);
	scaleUp_activity.addListener(animationListener);
	scaleUp_activity.playTogether(scaleUp_shadow);
	scaleUp_activity.playTogether(alpha_menu);
	scaleUp_activity.start();
}
 
Example 4
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * show the reside menu;
 */
public void openMenu(int direction) {

	setScaleDirection(direction);

	isOpened = true;
	AnimatorSet scaleDown_activity = buildScaleDownAnimation(viewActivity,
			mScaleValue, mScaleValue);
	AnimatorSet scaleDown_shadow = buildScaleDownAnimation(imageViewShadow,
			mScaleValue + shadowAdjustScaleX, mScaleValue
					+ shadowAdjustScaleY);
	// AnimatorSet scaleDown_activity =
	// buildMoveRightAnimation(viewActivity,
	// getScreenWidth()*(mScaleValue + shadowAdjustScaleX));
	// AnimatorSet scaleDown_shadow =
	// buildMoveRightAnimation(imageViewShadow,
	// getScreenWidth()*(mScaleValue + shadowAdjustScaleX));
	AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 1.0f);
	scaleDown_shadow.addListener(animationListener);
	scaleDown_activity.playTogether(scaleDown_shadow);
	scaleDown_activity.playTogether(alpha_menu);
	scaleDown_activity.start();
}
 
Example 5
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * show the reside menu;
 */
public void openMenu(int direction) {

	setScaleDirection(direction);

	isOpened = true;
	AnimatorSet scaleDown_activity = buildScaleDownAnimation(viewActivity,
			mScaleValue, mScaleValue);
	AnimatorSet scaleDown_shadow = buildScaleDownAnimation(imageViewShadow,
			mScaleValue + shadowAdjustScaleX, mScaleValue
					+ shadowAdjustScaleY);
	// AnimatorSet scaleDown_activity =
	// buildMoveRightAnimation(viewActivity,
	// getScreenWidth()*(mScaleValue + shadowAdjustScaleX));
	// AnimatorSet scaleDown_shadow =
	// buildMoveRightAnimation(imageViewShadow,
	// getScreenWidth()*(mScaleValue + shadowAdjustScaleX));
	AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 1.0f);
	scaleDown_shadow.addListener(animationListener);
	scaleDown_activity.playTogether(scaleDown_shadow);
	scaleDown_activity.playTogether(alpha_menu);
	scaleDown_activity.start();
}
 
Example 6
Source File: SwipeUndoTouchListener.java    From ListViewAnimations with Apache License 2.0 6 votes vote down vote up
/**
 * Performs the undo animation and restores the original state for given {@link android.view.View}.
 *
 * @param view the parent {@code View} which contains both primary and undo {@code View}s.
 */
public void undo(@NonNull final View view) {
    int position = AdapterViewUtil.getPositionForView(getListViewWrapper(), view);
    mUndoPositions.remove(position);

    View primaryView = mCallback.getPrimaryView(view);
    View undoView = mCallback.getUndoView(view);

    primaryView.setVisibility(View.VISIBLE);

    ObjectAnimator undoAlphaAnimator = ObjectAnimator.ofFloat(undoView, ALPHA, 1f, 0f);
    ObjectAnimator primaryAlphaAnimator = ObjectAnimator.ofFloat(primaryView, ALPHA, 0f, 1f);
    ObjectAnimator primaryXAnimator = ObjectAnimator.ofFloat(primaryView, TRANSLATION_X, primaryView.getWidth(), 0f);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(undoAlphaAnimator, primaryAlphaAnimator, primaryXAnimator);
    animatorSet.addListener(new UndoAnimatorListener(undoView));
    animatorSet.start();

    mCallback.onUndo(view, position);
}
 
Example 7
Source File: MaterialRippleLayoutNineOld.java    From AdvancedMaterialDrawer with Apache License 2.0 5 votes vote down vote up
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled) return;

    float endRadius = getEndRadius();

    cancelAnimations();

    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });

    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);

    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
 
Example 8
Source File: CellViewHolder.java    From MaterialLeanBack with Apache License 2.0 5 votes vote down vote up
public void reduce(boolean withAnimation) {
    if (enlarged && settings.animateCards) {
        if (currentAnimator != null) {
            currentAnimator.cancel();
            currentAnimator = null;
        }

        int duration = withAnimation ? 300 : 0;

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(duration);

        List<Animator> animatorList = new ArrayList<>();
        animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleX", scaleReduced));
        animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleY", scaleReduced));

        if (settings.overlapCards) {
            //animatorList.add(ObjectAnimator.ofFloat(cardView, "translationX", translationX));
            animatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    cardView.setCardElevation(settings.elevationReduced);
                    currentAnimator = null;
                }
            });
        }

        animatorSet.playTogether(animatorList);
        currentAnimator = animatorSet;
        animatorSet.start();

        enlarged = false;
    }
}
 
Example 9
Source File: ResideMenu.java    From AndroidResideMenu with MIT License 5 votes vote down vote up
/**
 * Close the menu;
 */
public void closeMenu() {

    isOpened = false;
    AnimatorSet scaleUp_activity = buildScaleUpAnimation(viewActivity, 1.0f, 1.0f);
    AnimatorSet scaleUp_shadow = buildScaleUpAnimation(imageViewShadow, 1.0f, 1.0f);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 0.0f);
    scaleUp_activity.addListener(animationListener);
    scaleUp_activity.playTogether(scaleUp_shadow);
    scaleUp_activity.playTogether(alpha_menu);
    scaleUp_activity.start();
}
 
Example 10
Source File: CellViewHolder.java    From MaterialLeanBack with Apache License 2.0 5 votes vote down vote up
public void enlarge(boolean withAnimation) {
    if (!enlarged && settings.animateCards) {

        if (currentAnimator != null) {
            currentAnimator.cancel();
            currentAnimator = null;
        }

        int duration = withAnimation ? 300 : 0;

        adapter.itemPosition = getAdapterPosition();

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(duration);

        List<Animator> animatorList = new ArrayList<>();
        animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleX", scaleEnlarged));
        animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleY", scaleEnlarged));

        if (settings.overlapCards) {
            //animatorList.add(ObjectAnimator.ofFloat(cardView, "translationX", translationX));
            animatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    cardView.setCardElevation(settings.elevationEnlarged);
                    currentAnimator = null;
                }
            });
        }

        animatorSet.playTogether(animatorList);
        currentAnimator = animatorSet;
        animatorSet.start();

        enlarged = true;
    }
}
 
Example 11
Source File: ResideMenu.java    From GifAssistant with Apache License 2.0 5 votes vote down vote up
/**
 * close the reslide menu;
 */
public void closeMenu(){

    isOpened = false;
    AnimatorSet scaleUp_activity = buildScaleUpAnimation(viewActivity, 1.0f, 1.0f);
    AnimatorSet scaleUp_shadow = buildScaleUpAnimation(imageViewShadow, 1.0f, 1.0f);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 0.0f);
    scaleUp_activity.addListener(animationListener);
    scaleUp_activity.playTogether(scaleUp_shadow);
    scaleUp_activity.playTogether(alpha_menu);
    scaleUp_activity.start();
}
 
Example 12
Source File: SwipeTouchListener.java    From ListViewAnimations with Apache License 2.0 5 votes vote down vote up
/**
 * Animates the pending {@link android.view.View} back to its original position.
 */
private void restoreCurrentViewTranslation() {
    if (mCurrentView == null) {
        return;
    }

    ObjectAnimator xAnimator = ObjectAnimator.ofFloat(mSwipingView, TRANSLATION_X, 0);
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mSwipingView, ALPHA, 1);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(xAnimator, alphaAnimator);
    animatorSet.setDuration(mAnimationTime);
    animatorSet.addListener(new RestoreAnimatorListener(mCurrentView, mCurrentPosition));
    animatorSet.start();
}
 
Example 13
Source File: ResideMenu.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * close the reslide main;
 */
public void closeMenu(){

    isOpened = false;
    AnimatorSet scaleUp_activity = buildScaleUpAnimation(view_activity, 1.0f, 1.0f);
    AnimatorSet scaleUp_shadow = buildScaleUpAnimation(iv_shadow, 1.0f, 1.0f);
    AnimatorSet alpha_menu = buildMenuAnimation(sv_menu, 0.0f);
    scaleUp_activity.addListener(animationListener);
    scaleUp_activity.playTogether(scaleUp_shadow);
    scaleUp_activity.playTogether(alpha_menu);
    scaleUp_activity.start();
}
 
Example 14
Source File: AnimateAdditionAdapter.java    From ListViewAnimations with Apache License 2.0 5 votes vote down vote up
@Override
@NonNull
public View getView(final int position, @Nullable final View convertView, @NonNull final ViewGroup parent) {
    final View view = super.getView(position, convertView, parent);

    if (mInsertQueue.getActiveIndexes().contains(position)) {
        int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.MATCH_PARENT, View.MeasureSpec.AT_MOST);
        int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED);
        view.measure(widthMeasureSpec, heightMeasureSpec);

        int originalHeight = view.getMeasuredHeight();

        ValueAnimator heightAnimator = ValueAnimator.ofInt(1, originalHeight);
        heightAnimator.addUpdateListener(new HeightUpdater(view));

        Animator[] customAnimators = getAdditionalAnimators(view, parent);
        Animator[] animators = new Animator[customAnimators.length + 1];
        animators[0] = heightAnimator;
        System.arraycopy(customAnimators, 0, animators, 1, customAnimators.length);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);

        ViewHelper.setAlpha(view, 0);
        ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);

        AnimatorSet allAnimatorsSet = new AnimatorSet();
        allAnimatorsSet.playSequentially(animatorSet, alphaAnimator);

        allAnimatorsSet.setDuration(mInsertionAnimationDurationMs);
        allAnimatorsSet.addListener(new ExpandAnimationListener(position));
        allAnimatorsSet.start();
    }

    return view;
}
 
Example 15
Source File: VideoImageView.java    From Studio with Apache License 2.0 5 votes vote down vote up
private void nextAnimation() {
    AnimatorSet anim = new AnimatorSet();
    if (scale) {
        anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1.5f, 1f),
                ObjectAnimator.ofFloat(this, "scaleY", 1.5f, 1f));
    }
    else {
        anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1, 1.5f),
                ObjectAnimator.ofFloat(this, "scaleY", 1, 1.5f));
    }
    anim.setDuration(10987);
    anim.addListener(this);
    anim.start();
    scale = !scale;
}
 
Example 16
Source File: AnimateDismissAdapter.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Animate dismissal of the items at given positions.
 */
public void animateDismiss(final Collection<Integer> positions) {
    final List<Integer> positionsCopy = new ArrayList<Integer>(positions);
    if (getAbsListView() == null) {
        throw new IllegalStateException("Call setAbsListView() on this AnimateDismissAdapter before calling setAdapter()!");
    }

    List<View> views = getVisibleViewsForPositions(positionsCopy);

    if (!views.isEmpty()) {
        List<Animator> animators = new ArrayList<Animator>();
        for (final View view : views) {
            animators.add(createAnimatorForView(view));
        }

        AnimatorSet animatorSet = new AnimatorSet();

        Animator[] animatorsArray = new Animator[animators.size()];
        for (int i = 0; i < animatorsArray.length; i++) {
            animatorsArray[i] = animators.get(i);
        }

        animatorSet.playTogether(animatorsArray);
        animatorSet.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(final Animator animator) {
                invokeCallback(positionsCopy);
            }
        });
        animatorSet.start();
    } else {
        invokeCallback(positionsCopy);
    }
}
 
Example 17
Source File: ResideMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * show the reside menu;
 */
public void openMenu(int direction){

    setScaleDirection(direction);

    isOpened = true;
    AnimatorSet scaleDown_activity = buildScaleDownAnimation(viewActivity, mScaleValue, mScaleValue);
    AnimatorSet scaleDown_shadow = buildScaleDownAnimation(imageViewShadow,
    		mScaleValue + shadowAdjustScaleX, mScaleValue + shadowAdjustScaleY);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 1.0f);
    scaleDown_shadow.addListener(animationListener);
    scaleDown_activity.playTogether(scaleDown_shadow);
    scaleDown_activity.playTogether(alpha_menu);
    scaleDown_activity.start();
}
 
Example 18
Source File: ResideMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * close the reslide menu;
 */
public void closeMenu(){

    isOpened = false;
    AnimatorSet scaleUp_activity = buildScaleUpAnimation(viewActivity, 1.0f, 1.0f);
    AnimatorSet scaleUp_shadow = buildScaleUpAnimation(imageViewShadow, 1.0f, 1.0f);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 0.0f);
    scaleUp_activity.addListener(animationListener);
    scaleUp_activity.playTogether(scaleUp_shadow);
    scaleUp_activity.playTogether(alpha_menu);
    scaleUp_activity.start();
}
 
Example 19
Source File: AnimateDismissAdapter.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
/**
 * Animate dismissal of the items at given positions.
 */
public void animateDismiss(final Collection<Integer> positions) {
    final List<Integer> positionsCopy = new ArrayList<Integer>(positions);
    if (getAbsListView() == null) {
        throw new IllegalStateException("Call setAbsListView() on this AnimateDismissAdapter before calling setAdapter()!");
    }

    List<View> views = getVisibleViewsForPositions(positionsCopy);

    if (!views.isEmpty()) {
        List<Animator> animators = new ArrayList<Animator>();
        for (final View view : views) {
            animators.add(createAnimatorForView(view));
        }

        AnimatorSet animatorSet = new AnimatorSet();

        Animator[] animatorsArray = new Animator[animators.size()];
        for (int i = 0; i < animatorsArray.length; i++) {
            animatorsArray[i] = animators.get(i);
        }

        animatorSet.playTogether(animatorsArray);
        animatorSet.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(final Animator animator) {
                invokeCallback(positionsCopy);
            }
        });
        animatorSet.start();
    } else {
        invokeCallback(positionsCopy);
    }
}
 
Example 20
Source File: ResideMenu.java    From AndroidResideMenu with MIT License 5 votes vote down vote up
/**
 * Show the menu;
 */
public void openMenu(int direction) {

    setScaleDirection(direction);

    isOpened = true;
    AnimatorSet scaleDown_activity = buildScaleDownAnimation(viewActivity, mScaleValue, mScaleValue);
    AnimatorSet scaleDown_shadow = buildScaleDownAnimation(imageViewShadow,
            mScaleValue + shadowAdjustScaleX, mScaleValue + shadowAdjustScaleY);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 1.0f);
    scaleDown_shadow.addListener(animationListener);
    scaleDown_activity.playTogether(scaleDown_shadow);
    scaleDown_activity.playTogether(alpha_menu);
    scaleDown_activity.start();
}