From 9f1ac3976ea3aa08c20c06fa6678e367e1ed424d Mon Sep 17 00:00:00 2001 From: George Mount Date: Sun, 7 Sep 2014 15:04:03 -0700 Subject: [PATCH] Improve Visibility parent value check. Bug 17412818 Bug 16398271 The Visibility Transition must not run against children that are already disappearing or there will be, for example, a double fade-out effect. Before this change, if a parent matched another view, it would prevent its child from disappearing. This change also removes using the overlay for children that have been removed from the view hierarchy indirectly. This prevents ListView and RecyclerView children from being added to the overlay. Change-Id: Iac0610f0939da8643b98812ee1ec1c8d1d70a215 --- core/java/android/transition/Visibility.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/java/android/transition/Visibility.java b/core/java/android/transition/Visibility.java index 0b0255221a059..d648ca627b9dc 100644 --- a/core/java/android/transition/Visibility.java +++ b/core/java/android/transition/Visibility.java @@ -358,12 +358,16 @@ public abstract class Visibility extends Transition { overlayView = startView; } else if (startView.getParent() instanceof View) { View startParent = (View) startView.getParent(); - if (!isValidTarget(startParent)) { - if (startView.isAttachedToWindow()) { - overlayView = copyViewImage(startView); - } else { - overlayView = startView; - } + VisibilityInfo parentVisibilityInfo = null; + TransitionValues endParentValues = getMatchedTransitionValues(startParent, + true); + if (endParentValues != null) { + TransitionValues startParentValues = getTransitionValues(startParent, true); + parentVisibilityInfo = + getVisibilityChangeInfo(startParentValues, endParentValues); + } + if (parentVisibilityInfo == null || !parentVisibilityInfo.visibilityChange) { + overlayView = copyViewImage(startView); } else if (startParent.getParent() == null) { int id = startParent.getId(); if (id != View.NO_ID && sceneRoot.findViewById(id) != null