diff options
author | Winson Chung <winsonc@google.com> | 2011-02-02 15:25:58 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-02-02 17:18:37 -0800 |
commit | c0844aa8a135bbf56aad2f95f57d1354a1260078 (patch) | |
tree | b652edb62df04310c84cd20b321613049853f100 /src/com | |
parent | 98ed6bbec7ea8776c2a0b76429e47c2c7fc523e5 (diff) | |
download | packages_apps_trebuchet-c0844aa8a135bbf56aad2f95f57d1354a1260078.zip packages_apps_trebuchet-c0844aa8a135bbf56aad2f95f57d1354a1260078.tar.gz packages_apps_trebuchet-c0844aa8a135bbf56aad2f95f57d1354a1260078.tar.bz2 |
Fixing issue where we weren't picking up minute touch movements. (3413433)
Change-Id: I5920e5e7ad6fa758093deeb545d6d3b81f730198
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 6138b86..877f9d9 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -79,6 +79,7 @@ public abstract class PagedView extends ViewGroup { private float mDownMotionX; protected float mLastMotionX; + protected float mLastMotionXRemainder; protected float mLastMotionY; private int mLastScreenCenter = -1; @@ -761,6 +762,7 @@ public abstract class PagedView extends ViewGroup { mDownMotionX = x; mLastMotionX = x; mLastMotionY = y; + mLastMotionXRemainder = 0; mActivePointerId = ev.getPointerId(0); mAllowLongPress = true; @@ -854,6 +856,7 @@ public abstract class PagedView extends ViewGroup { // Scroll if the user moved far enough along the X axis mTouchState = TOUCH_STATE_SCROLLING; mLastMotionX = x; + mLastMotionXRemainder = 0; mTouchX = mScrollX; mSmoothingTime = System.nanoTime() / NANOTIME_DIV; pageBeginMoving(); @@ -934,6 +937,7 @@ public abstract class PagedView extends ViewGroup { // Remember where the motion event started mDownMotionX = mLastMotionX = ev.getX(); + mLastMotionXRemainder = 0; mActivePointerId = ev.getPointerId(0); if (mTouchState == TOUCH_STATE_SCROLLING) { pageBeginMoving(); @@ -945,17 +949,21 @@ public abstract class PagedView extends ViewGroup { // Scroll to follow the motion event final int pointerIndex = ev.findPointerIndex(mActivePointerId); final float x = ev.getX(pointerIndex); - final int deltaX = (int) (mLastMotionX - x); - mLastMotionX = x; + final float deltaX = mLastMotionX + mLastMotionXRemainder - x; - if (deltaX != 0) { + // Only scroll and update mLastMotionX if we have moved some discrete amount. We + // keep the remainder because we are actually testing if we've moved from the last + // scrolled position (which is discrete). + if (Math.abs(deltaX) >= 1.0f) { mTouchX += deltaX; mSmoothingTime = System.nanoTime() / NANOTIME_DIV; if (!mDeferScrollUpdate) { - scrollBy(deltaX, 0); + scrollBy((int) deltaX, 0); } else { invalidate(); } + mLastMotionX = x; + mLastMotionXRemainder = deltaX - (int) deltaX; } else { awakenScrollBars(); } @@ -1057,6 +1065,7 @@ public abstract class PagedView extends ViewGroup { final int newPointerIndex = pointerIndex == 0 ? 1 : 0; mLastMotionX = mDownMotionX = ev.getX(newPointerIndex); mLastMotionY = ev.getY(newPointerIndex); + mLastMotionXRemainder = 0; mActivePointerId = ev.getPointerId(newPointerIndex); if (mVelocityTracker != null) { mVelocityTracker.clear(); |