diff options
| author | 2010-10-04 16:47:19 -0700 | |
|---|---|---|
| committer | 2010-10-04 16:58:04 -0700 | |
| commit | 5d6d7b9c3d76ba0bf72906d54c2ef366be149a23 (patch) | |
| tree | 520b2e7b232f0e927b6a16ea8c81bc5750206ecf | |
| parent | 5e25c2c14593caee5638603120553ae1ec530f85 (diff) | |
Changed LayoutTransition to disable animations when set to null
Change-Id: Ic4d67135a273ea816c3d15bce05da611bd6bae53
| -rw-r--r-- | core/java/android/animation/LayoutTransition.java | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/core/java/android/animation/LayoutTransition.java b/core/java/android/animation/LayoutTransition.java index 8f087d51b366..52f0f1634297 100644 --- a/core/java/android/animation/LayoutTransition.java +++ b/core/java/android/animation/LayoutTransition.java @@ -459,21 +459,22 @@ public class LayoutTransition { * @param transitionType one of {@link #CHANGE_APPEARING}, {@link #CHANGE_DISAPPEARING}, * {@link #APPEARING}, or {@link #DISAPPEARING}, which determines the animation whose * duration is being set. - * @param animator The animation being assigned. + * @param animator The animation being assigned. A value of <code>null</code> means that no + * animation will be run for the specified transitionType. */ public void setAnimator(int transitionType, Animator animator) { switch (transitionType) { case CHANGE_APPEARING: - mChangingAppearingAnim = (animator != null) ? animator : defaultChangeIn; + mChangingAppearingAnim = animator; break; case CHANGE_DISAPPEARING: - mChangingDisappearingAnim = (animator != null) ? animator : defaultChangeOut; + mChangingDisappearingAnim = animator; break; case APPEARING: - mAppearingAnim = (animator != null) ? animator : defaultFadeIn; + mAppearingAnim = animator; break; case DISAPPEARING: - mDisappearingAnim = (animator != null) ? animator : defaultFadeOut; + mDisappearingAnim = animator; break; } } @@ -516,6 +517,14 @@ public class LayoutTransition { * transition is occuring because an item is being added to or removed from the parent. */ private void runChangeTransition(final ViewGroup parent, View newView, final int changeReason) { + + Animator baseAnimator = (changeReason == APPEARING) ? + mChangingAppearingAnim : mChangingDisappearingAnim; + // If the animation is null, there's nothing to do + if (baseAnimator == null) { + return; + } + // reset the inter-animation delay, in case we use it later staggerDelay = 0; @@ -540,9 +549,7 @@ public class LayoutTransition { } // Make a copy of the appropriate animation - final Animator anim = (changeReason == APPEARING) ? - mChangingAppearingAnim.clone() : - mChangingDisappearingAnim.clone(); + final Animator anim = baseAnimator.clone(); // Cache the animation in case we need to cancel it later currentAnimations.put(child, anim); @@ -633,6 +640,14 @@ public class LayoutTransition { * @param child The View being added to the ViewGroup. */ private void runAppearingTransition(final ViewGroup parent, final View child) { + if (mAppearingAnim == null) { + if (mListeners != null) { + for (TransitionListener listener : mListeners) { + listener.endTransition(LayoutTransition.this, parent, child, APPEARING); + } + } + return; + } Animator anim = mAppearingAnim.clone(); anim.setTarget(child); anim.setStartDelay(mAppearingDelay); @@ -659,6 +674,14 @@ public class LayoutTransition { * @param child The View being removed from the ViewGroup. */ private void runDisappearingTransition(final ViewGroup parent, final View child) { + if (mDisappearingAnim == null) { + if (mListeners != null) { + for (TransitionListener listener : mListeners) { + listener.endTransition(LayoutTransition.this, parent, child, DISAPPEARING); + } + } + return; + } Animator anim = mDisappearingAnim.clone(); anim.setStartDelay(mDisappearingDelay); anim.setDuration(mDisappearingDuration); |