summaryrefslogtreecommitdiffstats
path: root/core/java/android/animation
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2012-05-23 13:28:22 -0700
committerChet Haase <chet@google.com>2012-05-23 14:09:30 -0700
commitab3a776827365b6bb413052a5e093bbc87265728 (patch)
tree6c9455037e6b2e2ceb8972904bc2e1c8542ef709 /core/java/android/animation
parent53d003f0e77291e7382c4871e0828014b470ab9f (diff)
downloadframeworks_base-ab3a776827365b6bb413052a5e093bbc87265728.zip
frameworks_base-ab3a776827365b6bb413052a5e093bbc87265728.tar.gz
frameworks_base-ab3a776827365b6bb413052a5e093bbc87265728.tar.bz2
Avoid running layout transitions on unattached views and windows
LayoutTransition causes artifacts in some situations where a window is just becoming visible or a container is just being added to the view tree when animations are kicked off in LayoutTransition due to the normal automatic mechanism of running animations when views are added/removed/etc. The problem is that containers in these situations may have children with positions and sizes of (0, 0), causing the animation to animate from this default/nonsense value to whatever is appropriate for the views when they are first laid out and drawn. The end result is correct, but the animation is superfluous and silly. The fix is to avoid running any kind of transition animation on windows that are not currently visible or containers that are not currently atached to the view hierarchy. This should avoid the situation by only allowing the animations to run after the containers and windows are visible and set up correctly. Issue #6544410 issue with layout transition when first showing the activity Change-Id: I737b2598887ef806dec3b02a483a8e8ff2c3d4e2
Diffstat (limited to 'core/java/android/animation')
-rw-r--r--core/java/android/animation/LayoutTransition.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/animation/LayoutTransition.java b/core/java/android/animation/LayoutTransition.java
index c643137..bdcb2af 100644
--- a/core/java/android/animation/LayoutTransition.java
+++ b/core/java/android/animation/LayoutTransition.java
@@ -1208,6 +1208,9 @@ public class LayoutTransition {
* affect CHANGE_APPEARING or CHANGE_DISAPPEARING animations.
*/
private void addChild(ViewGroup parent, View child, boolean changesLayout) {
+ if (parent.getWindowVisibility() != View.VISIBLE) {
+ return;
+ }
if ((mTransitionTypes & FLAG_APPEARING) == FLAG_APPEARING) {
// Want disappearing animations to finish up before proceeding
cancel(DISAPPEARING);
@@ -1243,6 +1246,9 @@ public class LayoutTransition {
* @hide
*/
public void layoutChange(ViewGroup parent) {
+ if (parent.getWindowVisibility() != View.VISIBLE) {
+ return;
+ }
if ((mTransitionTypes & FLAG_CHANGING) == FLAG_CHANGING && !isRunning()) {
// This method is called for all calls to layout() in the container, including
// those caused by add/remove/hide/show events, which will already have set up
@@ -1301,6 +1307,9 @@ public class LayoutTransition {
* affect CHANGE_APPEARING or CHANGE_DISAPPEARING animations.
*/
private void removeChild(ViewGroup parent, View child, boolean changesLayout) {
+ if (parent.getWindowVisibility() != View.VISIBLE) {
+ return;
+ }
if ((mTransitionTypes & FLAG_DISAPPEARING) == FLAG_DISAPPEARING) {
// Want appearing animations to finish up before proceeding
cancel(APPEARING);