summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/PagedView.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-02-03 11:36:24 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-02-03 11:36:24 -0800
commitcc377b516c179822b6475673e0b07faad5297361 (patch)
treed74762191d5130618e4755e932540df5eecbbaf1 /src/com/android/launcher2/PagedView.java
parente95c8ee998bc04c64c29c0594d81aeb283b05c1f (diff)
parentc0844aa8a135bbf56aad2f95f57d1354a1260078 (diff)
downloadandroid_packages_apps_Trebuchet-cc377b516c179822b6475673e0b07faad5297361.tar.gz
android_packages_apps_Trebuchet-cc377b516c179822b6475673e0b07faad5297361.tar.bz2
android_packages_apps_Trebuchet-cc377b516c179822b6475673e0b07faad5297361.zip
Merge "Fixing issue where we weren't picking up minute touch movements. (3413433)" into honeycomb
Diffstat (limited to 'src/com/android/launcher2/PagedView.java')
-rw-r--r--src/com/android/launcher2/PagedView.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index e65c196fe..96b0551ae 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();