summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-10-26 13:19:15 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-10-26 13:19:15 -0700
commit44ccb2ae8a56ee2b45f64369cd9e23a0d844e060 (patch)
treed79d4f34653637292089edd7caaefeec50270344 /src
parentb3c81cc83c3c375933d35e82eea84e212a2e87ef (diff)
parent9cfd25f16739548111ba8fc6ba8cd83010eccef6 (diff)
downloadandroid_packages_apps_Trebuchet-44ccb2ae8a56ee2b45f64369cd9e23a0d844e060.tar.gz
android_packages_apps_Trebuchet-44ccb2ae8a56ee2b45f64369cd9e23a0d844e060.tar.bz2
android_packages_apps_Trebuchet-44ccb2ae8a56ee2b45f64369cd9e23a0d844e060.zip
Merge "Adding distance threshold to initiate paging regardless of velocity."
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/PagedView.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 4ccc4aeab..9739b156f 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -53,7 +53,9 @@ public abstract class PagedView extends ViewGroup {
protected static final int INVALID_PAGE = -1;
// the min drag distance for a fling to register, to prevent random page shifts
- private static final int MIN_LENGTH_FOR_FLING = 50;
+ private static final int MIN_LENGTH_FOR_FLING = 25;
+ // The min drag distance to trigger a page shift (regardless of velocity)
+ private static final int MIN_LENGTH_FOR_MOVE = 200;
private static final int PAGE_SNAP_ANIMATION_DURATION = 1000;
protected static final float NANOTIME_DIV = 1000000000.0f;
@@ -836,12 +838,17 @@ public abstract class PagedView extends ViewGroup {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
int velocityX = (int) velocityTracker.getXVelocity(activePointerId);
- boolean isfling = Math.abs(mDownMotionX - x) > MIN_LENGTH_FOR_FLING;
+ final int deltaX = (int) (x - mDownMotionX);
+ boolean isfling = Math.abs(deltaX) > MIN_LENGTH_FOR_FLING;
+ boolean isSignificantMove = Math.abs(deltaX) > MIN_LENGTH_FOR_MOVE;
final int snapVelocity = mSnapVelocity;
- if (isfling && velocityX > snapVelocity && mCurrentPage > 0) {
+ if ((isSignificantMove && deltaX > 0 ||
+ (isfling && velocityX > snapVelocity)) &&
+ mCurrentPage > 0) {
snapToPageWithVelocity(mCurrentPage - 1, velocityX);
- } else if (isfling && velocityX < -snapVelocity &&
+ } else if ((isSignificantMove && deltaX < 0 ||
+ (isfling && velocityX < -snapVelocity)) &&
mCurrentPage < getChildCount() - 1) {
snapToPageWithVelocity(mCurrentPage + 1, velocityX);
} else {