summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-10-24 16:09:28 -0700
committerWinson Chung <winsonc@google.com>2010-10-25 10:47:40 -0700
commit9cfd25f16739548111ba8fc6ba8cd83010eccef6 (patch)
treeab6f8a2acb4fb762606d7cf4199d1382831f8f4b /src/com
parent4c0505dcc2686fcb04ec6340869af4ee825dcb98 (diff)
downloadandroid_packages_apps_Trebuchet-9cfd25f16739548111ba8fc6ba8cd83010eccef6.tar.gz
android_packages_apps_Trebuchet-9cfd25f16739548111ba8fc6ba8cd83010eccef6.tar.bz2
android_packages_apps_Trebuchet-9cfd25f16739548111ba8fc6ba8cd83010eccef6.zip
Adding distance threshold to initiate paging regardless of velocity.
Change-Id: I275417ca69bcaa0b643dab7f3f552d973a194ce6
Diffstat (limited to 'src/com')
-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 {