From ef3cbfd4c42719d3e4feabb74c08f0311066c194 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Wed, 21 Aug 2013 14:01:02 -0700 Subject: Cancel running LayoutTransition before removing it from a container Previously, setting a new LayoutTransition object on a container would not do anything to the old transition object (if it existed). This means that the previous transition could be mid-flight, changing stuff in that container, and would continue doing so even after it was removed. This could cause artifacts like that in the bug below where views that are fading out would be put in the containers "disappearing children" list for the duration of the fade... and then would never be removed from that list because the container was no longer connected to that transition. This caused items to stay visible even after they were removed from their parent containers. Issue #10119571 LayoutTransitions sometimes does not honor view's visibility Change-Id: I3efa4065e47fa97c4dd90410bbc1a0273c2b8079 --- core/java/android/view/ViewGroup.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index c874c82..d68c410 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -3855,12 +3855,17 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * the ViewGroup will be animated according to the animations defined in that LayoutTransition * object. By default, the transition object is null (so layout changes are not animated). * + *

Replacing a non-null transition will cause that previous transition to be + * canceled, if it is currently running, to restore this container to + * its correct post-transition state.

+ * * @param transition The LayoutTransition object that will animated changes in layout. A value * of null means no transition will run on layout changes. * @attr ref android.R.styleable#ViewGroup_animateLayoutChanges */ public void setLayoutTransition(LayoutTransition transition) { if (mTransition != null) { + mTransition.cancel(); mTransition.removeTransitionListener(mLayoutTransitionListener); } mTransition = transition; -- cgit v1.1