From df9de0b121973bb59f4b8a74ade3000ec201c503 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Mon, 10 Jan 2011 11:01:49 -0800 Subject: [PATCH] Fixing bug with workspace drop animation Change-Id: I4f7682e588730905170fd534a415688ebbf64eea --- src/com/android/launcher2/CellLayout.java | 14 +++++--------- src/com/android/launcher2/Workspace.java | 5 ++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 2359e322ad..1173e52f2a 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -963,14 +963,10 @@ public class CellLayout extends ViewGroup implements Dimmable, VisibilityChanged if (lp.animateDrop) { lp.animateDrop = false; - // This call needs to be posted since it results in a requestLayout() - // which shouldn't be called from within a layout pass (can cause a bad - // state of the tree). - post(new Runnable() { - public void run() { - ((Workspace) mParent).animateViewIntoPosition(child); - } - }); + // This call does not result in a requestLayout(), but at one point did. + // We need to be cautious about any method calls within the layout pass + // to insure we don't leave the view tree in a bad state. + ((Workspace) mParent).animateViewIntoPosition(child); } } } @@ -1392,7 +1388,7 @@ public class CellLayout extends ViewGroup implements Dimmable, VisibilityChanged lp.isDragging = false; lp.dropped = true; lp.animateDrop = animate; - child.setVisibility(View.VISIBLE); + child.setVisibility(View.INVISIBLE); child.requestLayout(); } } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 1085083f52..f66b09b492 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -1516,6 +1516,10 @@ public class Workspace extends SmoothPagedView lp.oldY = viewY - (parent.getTop() - mScrollY); } + /* + * We should be careful that this method cannot result in any synchronous requestLayout() + * calls, as it is called from onLayout(). + */ public void animateViewIntoPosition(final View view) { final CellLayout parent = (CellLayout) view.getParent(); final CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams(); @@ -1574,7 +1578,6 @@ public class Workspace extends SmoothPagedView } }); - view.setVisibility(View.INVISIBLE); mDropAnim.start(); }