Fixing issue where you couldn't drag an item multiple pages (issue 10754544)
-> 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
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 8cdd8e2..9cfb3d9 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -2153,19 +2153,11 @@
}
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) {