OSDN Git Service

Fixing issue where you couldn't drag an item multiple pages (issue 10754544)
authorAdam Cohen <adamcohen@google.com>
Mon, 30 Sep 2013 00:46:49 +0000 (17:46 -0700)
committerAdam Cohen <adamcohen@google.com>
Mon, 30 Sep 2013 01:13:25 +0000 (18:13 -0700)
-> This was caused by a strange race condition. The page snap time was equal to
   the delay to recheck whether to snap (in DragController). This meant that
   scrollRight()/Left() would get called, and the scroller would be finished
   however, the final computeScrollHelper() hadn't been called, so the mCurrentPage
   hadn't yet been incremented.
-> Fixed the underlying race condition.
-> Added suitable gap (150 ms) between the two delays.

Change-Id: If700eb9e14d77a174e4395ca6933119bdb0da768

src/com/android/launcher3/DragController.java
src/com/android/launcher3/PagedView.java
src/com/android/launcher3/Workspace.java

index 3c1a04c..5b5c35c 100644 (file)
@@ -50,7 +50,7 @@ public class DragController {
     public static int DRAG_ACTION_COPY = 1;
 
     private static final int SCROLL_DELAY = 500;
-    private static final int RESCROLL_DELAY = 750;
+    private static final int RESCROLL_DELAY = PagedView.PAGE_SNAP_ANIMATION_DURATION + 150;
 
     private static final boolean PROFILE_DRAWING_DURING_DRAG = false;
 
index 8cdd8e2..9cfb3d9 100644 (file)
@@ -2153,19 +2153,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
     }
 
     public void scrollLeft() {
-        if (mScroller.isFinished()) {
-            if (mCurrentPage > 0) snapToPage(mCurrentPage - 1);
-        } else {
-            if (mNextPage > 0) snapToPage(mNextPage - 1);
-        }
+        if (getNextPage() > 0) snapToPage(getNextPage() - 1);
     }
 
     public void scrollRight() {
-        if (mScroller.isFinished()) {
-            if (mCurrentPage < getChildCount() -1) snapToPage(mCurrentPage + 1);
-        } else {
-            if (mNextPage < getChildCount() -1) snapToPage(mNextPage + 1);
-        }
+        if (getNextPage() < getChildCount() -1) snapToPage(getNextPage() + 1);
     }
 
     public int getPageForView(View v) {
index 7f6964f..baddc2d 100644 (file)
@@ -1748,25 +1748,17 @@ public class Workspace extends SmoothPagedView
 
     protected void onStartReordering() {
         super.onStartReordering();
-        int count = getChildCount();
-        for (int i = 0; i < count; i++) {
-            ((CellLayout) getChildAt(i)).setUseActiveGlowBackground(true);
-        }
         showOutlines();
-
         // Reordering handles its own animations, disable the automatic ones.
         setLayoutTransition(null);
     }
 
     protected void onEndReordering() {
         super.onEndReordering();
-        int count = getChildCount();
-        for (int i = 0; i < count; i++) {
-            ((CellLayout) getChildAt(i)).setUseActiveGlowBackground(false);
-        }
-        hideOutlines();
 
+        hideOutlines();
         mScreenOrder.clear();
+        int count = getChildCount();
         for (int i = 0; i < count; i++) {
             CellLayout cl = ((CellLayout) getChildAt(i));
             mScreenOrder.add(getIdForScreen(cl));