Loading core/java/android/animation/LayoutTransition.java +29 −7 Original line number Diff line number Diff line Loading @@ -617,7 +617,6 @@ public class LayoutTransition { Animator prevAnimation = currentChangingAnimations.get(child); if (prevAnimation != null) { prevAnimation.cancel(); currentChangingAnimations.remove(child); } Animator pendingAnimation = pendingAnimations.get(child); if (pendingAnimation != null) { Loading @@ -639,7 +638,6 @@ public class LayoutTransition { }; // Remove the animation from the cache when it ends anim.addListener(new AnimatorListenerAdapter() { private boolean canceled = false; @Override public void onAnimationStart(Animator animator) { Loading @@ -654,17 +652,13 @@ public class LayoutTransition { @Override public void onAnimationCancel(Animator animator) { // we remove canceled animations immediately, not here canceled = true; child.removeOnLayoutChangeListener(listener); layoutChangeListenerMap.remove(child); } @Override public void onAnimationEnd(Animator animator) { if (!canceled) { currentChangingAnimations.remove(child); } if (mListeners != null) { for (TransitionListener listener : mListeners) { listener.endTransition(LayoutTransition.this, parent, child, Loading Loading @@ -718,6 +712,28 @@ public class LayoutTransition { return (currentChangingAnimations.size() > 0 || currentVisibilityAnimations.size() > 0); } /** * Cancels the currently running transition. Note that we cancel() the changing animations * but end() the visibility animations. This is because this method is currently called * in the context of starting a new transition, so we want to move things from their mid- * transition positions, but we want them to have their end-transition visibility. * * @hide */ public void cancel() { HashMap<View, Animator> currentAnimCopy = (HashMap<View, Animator>) currentChangingAnimations.clone(); for (Animator anim : currentAnimCopy.values()) { anim.cancel(); } currentChangingAnimations.clear(); currentAnimCopy = (HashMap<View, Animator>) currentVisibilityAnimations.clone(); for (Animator anim : currentAnimCopy.values()) { anim.end(); } currentVisibilityAnimations.clear(); } /** * This method runs the animation that makes an added item appear. * Loading Loading @@ -810,6 +826,9 @@ public class LayoutTransition { * @param child The View being added to the ViewGroup. */ public void addChild(ViewGroup parent, View child) { if (isRunning()) { cancel(); } if (mListeners != null) { for (TransitionListener listener : mListeners) { listener.startTransition(this, parent, child, APPEARING); Loading Loading @@ -842,6 +861,9 @@ public class LayoutTransition { * @param child The View being removed from the ViewGroup. */ public void removeChild(ViewGroup parent, View child) { if (isRunning()) { cancel(); } if (mListeners != null) { for (TransitionListener listener : mListeners) { listener.startTransition(this, parent, child, DISAPPEARING); Loading core/java/android/animation/ValueAnimator.java +9 −6 Original line number Diff line number Diff line Loading @@ -895,7 +895,14 @@ public class ValueAnimator extends Animator { throw new AndroidRuntimeException("Animators may only be run on Looper threads"); } mPlayingBackwards = playBackwards; mCurrentIteration = 0; mPlayingState = STOPPED; mStartedDelay = false; sPendingAnimations.get().add(this); if (mStartDelay == 0) { // This sets the initial value of the animation, prior to actually starting it running setCurrentPlayTime(getCurrentPlayTime()); if (mListeners != null) { ArrayList<AnimatorListener> tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone(); Loading @@ -904,13 +911,7 @@ public class ValueAnimator extends Animator { tmpListeners.get(i).onAnimationStart(this); } } // This sets the initial value of the animation, prior to actually starting it running setCurrentPlayTime(getCurrentPlayTime()); } mCurrentIteration = 0; mPlayingState = STOPPED; mStartedDelay = false; sPendingAnimations.get().add(this); AnimationHandler animationHandler = sAnimationHandler.get(); if (animationHandler == null) { animationHandler = new AnimationHandler(); Loading Loading @@ -947,6 +948,8 @@ public class ValueAnimator extends Animator { // Special case if the animation has not yet started; get it ready for ending mStartedDelay = false; startAnimation(); } else if (!mInitialized) { initAnimation(); } // The final value set on the target varies, depending on whether the animation // was supposed to repeat an odd number of times Loading core/java/android/view/ViewGroup.java +4 −0 Original line number Diff line number Diff line Loading @@ -2938,6 +2938,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager private void addViewInner(View child, int index, LayoutParams params, boolean preventRequestLayout) { if (mTransition != null && mTransition.isRunning()) { mTransition.cancel(); } if (child.getParent() != null) { throw new IllegalStateException("The specified child already has a parent. " + "You must call removeView() on the child's parent first."); Loading Loading
core/java/android/animation/LayoutTransition.java +29 −7 Original line number Diff line number Diff line Loading @@ -617,7 +617,6 @@ public class LayoutTransition { Animator prevAnimation = currentChangingAnimations.get(child); if (prevAnimation != null) { prevAnimation.cancel(); currentChangingAnimations.remove(child); } Animator pendingAnimation = pendingAnimations.get(child); if (pendingAnimation != null) { Loading @@ -639,7 +638,6 @@ public class LayoutTransition { }; // Remove the animation from the cache when it ends anim.addListener(new AnimatorListenerAdapter() { private boolean canceled = false; @Override public void onAnimationStart(Animator animator) { Loading @@ -654,17 +652,13 @@ public class LayoutTransition { @Override public void onAnimationCancel(Animator animator) { // we remove canceled animations immediately, not here canceled = true; child.removeOnLayoutChangeListener(listener); layoutChangeListenerMap.remove(child); } @Override public void onAnimationEnd(Animator animator) { if (!canceled) { currentChangingAnimations.remove(child); } if (mListeners != null) { for (TransitionListener listener : mListeners) { listener.endTransition(LayoutTransition.this, parent, child, Loading Loading @@ -718,6 +712,28 @@ public class LayoutTransition { return (currentChangingAnimations.size() > 0 || currentVisibilityAnimations.size() > 0); } /** * Cancels the currently running transition. Note that we cancel() the changing animations * but end() the visibility animations. This is because this method is currently called * in the context of starting a new transition, so we want to move things from their mid- * transition positions, but we want them to have their end-transition visibility. * * @hide */ public void cancel() { HashMap<View, Animator> currentAnimCopy = (HashMap<View, Animator>) currentChangingAnimations.clone(); for (Animator anim : currentAnimCopy.values()) { anim.cancel(); } currentChangingAnimations.clear(); currentAnimCopy = (HashMap<View, Animator>) currentVisibilityAnimations.clone(); for (Animator anim : currentAnimCopy.values()) { anim.end(); } currentVisibilityAnimations.clear(); } /** * This method runs the animation that makes an added item appear. * Loading Loading @@ -810,6 +826,9 @@ public class LayoutTransition { * @param child The View being added to the ViewGroup. */ public void addChild(ViewGroup parent, View child) { if (isRunning()) { cancel(); } if (mListeners != null) { for (TransitionListener listener : mListeners) { listener.startTransition(this, parent, child, APPEARING); Loading Loading @@ -842,6 +861,9 @@ public class LayoutTransition { * @param child The View being removed from the ViewGroup. */ public void removeChild(ViewGroup parent, View child) { if (isRunning()) { cancel(); } if (mListeners != null) { for (TransitionListener listener : mListeners) { listener.startTransition(this, parent, child, DISAPPEARING); Loading
core/java/android/animation/ValueAnimator.java +9 −6 Original line number Diff line number Diff line Loading @@ -895,7 +895,14 @@ public class ValueAnimator extends Animator { throw new AndroidRuntimeException("Animators may only be run on Looper threads"); } mPlayingBackwards = playBackwards; mCurrentIteration = 0; mPlayingState = STOPPED; mStartedDelay = false; sPendingAnimations.get().add(this); if (mStartDelay == 0) { // This sets the initial value of the animation, prior to actually starting it running setCurrentPlayTime(getCurrentPlayTime()); if (mListeners != null) { ArrayList<AnimatorListener> tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone(); Loading @@ -904,13 +911,7 @@ public class ValueAnimator extends Animator { tmpListeners.get(i).onAnimationStart(this); } } // This sets the initial value of the animation, prior to actually starting it running setCurrentPlayTime(getCurrentPlayTime()); } mCurrentIteration = 0; mPlayingState = STOPPED; mStartedDelay = false; sPendingAnimations.get().add(this); AnimationHandler animationHandler = sAnimationHandler.get(); if (animationHandler == null) { animationHandler = new AnimationHandler(); Loading Loading @@ -947,6 +948,8 @@ public class ValueAnimator extends Animator { // Special case if the animation has not yet started; get it ready for ending mStartedDelay = false; startAnimation(); } else if (!mInitialized) { initAnimation(); } // The final value set on the target varies, depending on whether the animation // was supposed to repeat an odd number of times Loading
core/java/android/view/ViewGroup.java +4 −0 Original line number Diff line number Diff line Loading @@ -2938,6 +2938,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager private void addViewInner(View child, int index, LayoutParams params, boolean preventRequestLayout) { if (mTransition != null && mTransition.isRunning()) { mTransition.cancel(); } if (child.getParent() != null) { throw new IllegalStateException("The specified child already has a parent. " + "You must call removeView() on the child's parent first."); Loading