summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornebkat <nebkat@gmail.com>2013-03-09 07:24:10 -0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-03-09 07:24:10 -0800
commit67e2e6bb787361b26f1c23b9fe94ce321f019994 (patch)
treedad236c65a082ac55f0a1b9a4933bf36ce0ff202 /src
parent01a434b14bf61cccdc65394959048d818afc0352 (diff)
parente401cb10d11c9515891777c9834e95a060cdbc2e (diff)
downloadpackages_apps_trebuchet-67e2e6bb787361b26f1c23b9fe94ce321f019994.zip
packages_apps_trebuchet-67e2e6bb787361b26f1c23b9fe94ce321f019994.tar.gz
packages_apps_trebuchet-67e2e6bb787361b26f1c23b9fe94ce321f019994.tar.bz2
Merge "Revert "Improve scroll responsiveness."" into cm-10.1
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedView.java94
1 files changed, 44 insertions, 50 deletions
diff --git a/src/com/cyanogenmod/trebuchet/PagedView.java b/src/com/cyanogenmod/trebuchet/PagedView.java
index d8fccbf..42ae968 100644
--- a/src/com/cyanogenmod/trebuchet/PagedView.java
+++ b/src/com/cyanogenmod/trebuchet/PagedView.java
@@ -174,7 +174,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// It true, use a different slop parameter (pagingTouchSlop = 2 * touchSlop) for deciding
// to switch to a new page
- protected boolean mUsePagingTouchSlop = false;
+ protected boolean mUsePagingTouchSlop = true;
// If true, the subclass should directly update scrollX itself in its computeScroll method
protected boolean mDeferScrollUpdate = false;
@@ -1216,23 +1216,21 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (mUsePagingTouchSlop ? xPaged : xMoved) {
// Scroll if the user moved far enough along the X axis
mTouchState = TOUCH_STATE_SCROLLING;
+ mTotalMotionX += Math.abs(mLastMotionX - x);
+ mLastMotionX = x;
mLastMotionXRemainder = 0;
mTouchX = mScrollX;
pageBeginMoving();
- // Early scroll by starting as soon as we detect it's okay to scroll
- // instead of waiting for vsync.
- initiateScroll(ev);
}
} else {
if (mUsePagingTouchSlop ? yPaged : yMoved) {
// Scroll if the user moved far enough along the X axis
mTouchState = TOUCH_STATE_SCROLLING;
+ mTotalMotionY += Math.abs(mLastMotionY - y);
+ mLastMotionY = y;
mLastMotionYRemainder = 0;
mTouchY = mScrollY;
pageBeginMoving();
- // Early scroll by starting as soon as we detect it's okay to scroll
- // instead of waiting for vsync.
- initiateScroll(ev);
}
}
// Either way, cancel any pending longpress
@@ -1240,48 +1238,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
- protected void initiateScroll(MotionEvent ev) {
- final int pointerIndex = ev.findPointerIndex(mActivePointerId);
- final float x = ev.getX(pointerIndex);
- final float deltaX = mLastMotionX + mLastMotionXRemainder - x;
- final float y = ev.getY(pointerIndex);
- final float deltaY = mLastMotionY + mLastMotionYRemainder - y;
-
- mTotalMotionX += Math.abs(deltaX);
- mTotalMotionY += Math.abs(deltaY);
-
- // 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(!mVertical ? deltaX : deltaY) >= 1.0f) {
- if (!mVertical) {
- mTouchX += deltaX;
- mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
- if (!mDeferScrollUpdate) {
- scrollBy((int) deltaX, 0);
- if (DEBUG) Log.d(TAG, "onTouchEvent().Scrolling: " + deltaX);
- } else {
- invalidate();
- }
- mLastMotionX = x;
- mLastMotionXRemainder = deltaX - (int) deltaX;
- } else {
- mTouchY += deltaY;
- mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
- if (!mDeferScrollUpdate) {
- scrollBy(0, (int) deltaY);
- if (DEBUG) Log.d(TAG, "onTouchEvent().Scrolling: " + deltaY);
- } else {
- invalidate();
- }
- mLastMotionY = y;
- mLastMotionYRemainder =- deltaY - (int) deltaY;
- }
- } else {
- awakenScrollBars();
- }
- }
-
protected void cancelCurrentPageLongPress() {
if (mAllowLongPress) {
mAllowLongPress = false;
@@ -1433,7 +1389,45 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
case MotionEvent.ACTION_MOVE:
if (mTouchState == TOUCH_STATE_SCROLLING) {
// Scroll to follow the motion event
- initiateScroll(ev);
+ final int pointerIndex = ev.findPointerIndex(mActivePointerId);
+ final float x = ev.getX(pointerIndex);
+ final float deltaX = mLastMotionX + mLastMotionXRemainder - x;
+ final float y = ev.getY(pointerIndex);
+ final float deltaY = mLastMotionY + mLastMotionYRemainder - y;
+
+ mTotalMotionX += Math.abs(deltaX);
+ mTotalMotionY += Math.abs(deltaY);
+
+ // 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(!mVertical ? deltaX : deltaY) >= 1.0f) {
+ if (!mVertical) {
+ mTouchX += deltaX;
+ mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
+ if (!mDeferScrollUpdate) {
+ scrollBy((int) deltaX, 0);
+ if (DEBUG) Log.d(TAG, "onTouchEvent().Scrolling: " + deltaX);
+ } else {
+ invalidate();
+ }
+ mLastMotionX = x;
+ mLastMotionXRemainder = deltaX - (int) deltaX;
+ } else {
+ mTouchY += deltaY;
+ mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
+ if (!mDeferScrollUpdate) {
+ scrollBy(0, (int) deltaY);
+ if (DEBUG) Log.d(TAG, "onTouchEvent().Scrolling: " + deltaY);
+ } else {
+ invalidate();
+ }
+ mLastMotionY = y;
+ mLastMotionYRemainder = deltaY - (int) deltaY;
+ }
+ } else {
+ awakenScrollBars();
+ }
} else {
determineScrollingStart(ev);
}