List of usage examples for android.animation Animator removeAllListeners
public void removeAllListeners()
From source file:Main.java
/** * Cancels an animation ensuring that if it has listeners, onCancel and onEnd * are not called.// w ww. jav a 2 s.c o m */ public static void cancelAnimationWithoutCallbacks(Animator animator) { if (animator != null) { animator.removeAllListeners(); animator.cancel(); } }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public void runPendingAnimations() { final AnimatorSet removeAnimatorSet = new AnimatorSet(); removeAnimatorSet.playTogether(mRemoveAnimatorsList); mRemoveAnimatorsList.clear();// w ww . j a v a2 s .co m final AnimatorSet addAnimatorSet = new AnimatorSet(); addAnimatorSet.playTogether(mAddAnimatorsList); mAddAnimatorsList.clear(); final AnimatorSet changeAnimatorSet = new AnimatorSet(); changeAnimatorSet.playTogether(mChangeAnimatorsList); mChangeAnimatorsList.clear(); final AnimatorSet moveAnimatorSet = new AnimatorSet(); moveAnimatorSet.playTogether(mMoveAnimatorsList); mMoveAnimatorsList.clear(); final AnimatorSet pendingAnimatorSet = new AnimatorSet(); pendingAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); dispatchFinishedWhenDone(); } }); // Required order: removes, then changes & moves simultaneously, then additions. There are // redundant edges because changes or moves may be empty, causing the removes to incorrectly // play immediately. pendingAnimatorSet.play(removeAnimatorSet).before(changeAnimatorSet); pendingAnimatorSet.play(removeAnimatorSet).before(moveAnimatorSet); pendingAnimatorSet.play(changeAnimatorSet).with(moveAnimatorSet); pendingAnimatorSet.play(addAnimatorSet).after(changeAnimatorSet); pendingAnimatorSet.play(addAnimatorSet).after(moveAnimatorSet); pendingAnimatorSet.start(); }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateAdd(final ViewHolder holder) { endAnimation(holder);/* w w w. ja v a 2 s .com*/ final float prevAlpha = holder.itemView.getAlpha(); holder.itemView.setAlpha(0f); final Animator addAnimator = ObjectAnimator.ofFloat(holder.itemView, View.ALPHA, 1f) .setDuration(getAddDuration()); addAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchAddStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); holder.itemView.setAlpha(prevAlpha); dispatchAddFinished(holder); } }); mAddAnimatorsList.add(addAnimator); mAnimators.put(holder, addAnimator); return true; }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateRemove(final ViewHolder holder) { endAnimation(holder);//from w w w . ja v a2 s . co m final float prevAlpha = holder.itemView.getAlpha(); final Animator removeAnimator = ObjectAnimator.ofFloat(holder.itemView, View.ALPHA, 0f); removeAnimator.setDuration(getRemoveDuration()); removeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); holder.itemView.setAlpha(prevAlpha); dispatchRemoveFinished(holder); } }); mRemoveAnimatorsList.add(removeAnimator); mAnimators.put(holder, removeAnimator); return true; }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);/*from w ww . ja v a2s . co m*/ final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:com.sysdata.widget.accordion.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);/*from www .ja v a2 s .c o m*/ final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(new FastOutSlowInInterpolator()); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:com.velli.passwordmanager.ActivityMain.java
public boolean lockDrawer(final boolean lock, boolean animate) { final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); boolean locked = isDrawerLocked(); if (drawer != null && lock != locked) { if (lock) { drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); } else {//from ww w .j a v a 2 s. c o m drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); if (!animate) { initDrawer(); } } if (animate) { final ValueAnimator anim = ValueAnimator.ofFloat(lock ? 0 : 1, lock ? 1 : 0); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float slideOffset = (Float) valueAnimator.getAnimatedValue(); mToolbarDrawerToggle.onDrawerSlide(drawer, slideOffset); } }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { anim.removeAllUpdateListeners(); if (!lock) { initDrawer(); } animation.removeAllListeners(); } }); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(500); anim.start(); } else { mToolbarDrawerToggle.onDrawerSlide(drawer, lock ? 1 : 0); } return true; } return false; }
From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java
private void revealIn() { mRevealCircle.setVisibility(View.VISIBLE); mRevealCircle.animate().scaleX(100).scaleY(100).setDuration(mRevealDuration) .setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new AnimatorListenerAdapter() { @Override//from w ww .j ava 2 s. com public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mAnimating = false; animation.removeAllListeners(); } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); mAnimating = true; } }).start(); }
From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java
private void revealOut() { mRevealCircle.animate().scaleX(1).scaleY(1).setDuration(mRevealDuration) .setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new AnimatorListenerAdapter() { @Override/*from w w w . j a v a 2 s . c om*/ public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mRevealCircle.setVisibility(View.GONE); animation.removeAllListeners(); mAnimating = false; } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); mAnimating = true; } }).start(); }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateChange(@NonNull final ViewHolder oldHolder, @NonNull final ViewHolder newHolder, @NonNull ItemHolderInfo preInfo, @NonNull ItemHolderInfo postInfo) { endAnimation(oldHolder);// www.j a va 2 s .c o m endAnimation(newHolder); final long changeDuration = getChangeDuration(); List<Object> payloads = preInfo instanceof PayloadItemHolderInfo ? ((PayloadItemHolderInfo) preInfo).getPayloads() : null; if (oldHolder == newHolder) { final Animator animator = ((OnAnimateChangeListener) newHolder).onAnimateChange(payloads, preInfo.left, preInfo.top, preInfo.right, preInfo.bottom, changeDuration); if (animator == null) { dispatchChangeFinished(newHolder, false); return false; } animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchChangeStarting(newHolder, false); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(newHolder); dispatchChangeFinished(newHolder, false); } }); mChangeAnimatorsList.add(animator); mAnimators.put(newHolder, animator); return true; } else if (!(oldHolder instanceof OnAnimateChangeListener) || !(newHolder instanceof OnAnimateChangeListener)) { // Both holders must implement OnAnimateChangeListener in order to animate. dispatchChangeFinished(oldHolder, true); dispatchChangeFinished(newHolder, true); return false; } final Animator oldChangeAnimator = ((OnAnimateChangeListener) oldHolder).onAnimateChange(oldHolder, newHolder, changeDuration); if (oldChangeAnimator != null) { oldChangeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchChangeStarting(oldHolder, true); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(oldHolder); dispatchChangeFinished(oldHolder, true); } }); mAnimators.put(oldHolder, oldChangeAnimator); mChangeAnimatorsList.add(oldChangeAnimator); } else { dispatchChangeFinished(oldHolder, true); } final Animator newChangeAnimator = ((OnAnimateChangeListener) newHolder).onAnimateChange(oldHolder, newHolder, changeDuration); if (newChangeAnimator != null) { newChangeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchChangeStarting(newHolder, false); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(newHolder); dispatchChangeFinished(newHolder, false); } }); mAnimators.put(newHolder, newChangeAnimator); mChangeAnimatorsList.add(newChangeAnimator); } else { dispatchChangeFinished(newHolder, false); } return true; }