From b209e634a29a0cb5514fafb4e5882ea49ba1cfa7 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Tue, 27 Mar 2012 17:09:36 -0700 Subject: Fixing small bug where final item position might not match preview Change-Id: I216bbf2b454f92cf02b2807f684054e4dce6a05d --- src/com/android/launcher2/CellLayout.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index ce914e17a..fb319fe0c 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -159,6 +159,7 @@ public class CellLayout extends ViewGroup { private Rect mOccupiedRect = new Rect(); private int[] mDirectionVector = new int[2]; int[] mPreviousReorderDirection = new int[2]; + private static final int INVALID_DIRECTION = -100; public CellLayout(Context context) { this(context, null); @@ -2215,15 +2216,16 @@ public class CellLayout extends ViewGroup { // When we are checking drop validity or actually dropping, we don't recompute the // direction vector, since we want the solution to match the preview, and it's possible // that the exact position of the item has changed to result in a new reordering outcome. - if ((mode == MODE_ON_DROP || mode == MODE_ACCEPT_DROP) - && mPreviousReorderDirection[0] != -1) { + if ((mode == MODE_ON_DROP || mode == MODE_ON_DROP_EXTERNAL || mode == MODE_ACCEPT_DROP) + && mPreviousReorderDirection[0] != INVALID_DIRECTION) { mDirectionVector[0] = mPreviousReorderDirection[0]; mDirectionVector[1] = mPreviousReorderDirection[1]; // We reset this vector after drop - if (mode == MODE_ON_DROP) { - mPreviousReorderDirection[0] = -1; - mPreviousReorderDirection[1] = -1; + if (mode == MODE_ON_DROP || mode == MODE_ON_DROP_EXTERNAL) { + mPreviousReorderDirection[0] = INVALID_DIRECTION; + mPreviousReorderDirection[1] = INVALID_DIRECTION; } + } else { getDirectionVectorForDrop(pixelX, pixelY, spanX, spanY, dragView, mDirectionVector); mPreviousReorderDirection[0] = mDirectionVector[0]; -- cgit v1.2.3