diff options
author | Yorke Lee <yorkelee@google.com> | 2014-05-08 10:15:20 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-05-12 10:48:25 -0700 |
commit | 43943d8bbc628c7d6e0c3afe49e43161cbaf8b12 (patch) | |
tree | 65308bac830cc1e985c7356653ac6f2eda41bafd | |
parent | 809146690d03b3ec3404c37c1fb467f7b7234692 (diff) | |
download | frameworks_base-43943d8bbc628c7d6e0c3afe49e43161cbaf8b12.zip frameworks_base-43943d8bbc628c7d6e0c3afe49e43161cbaf8b12.tar.gz frameworks_base-43943d8bbc628c7d6e0c3afe49e43161cbaf8b12.tar.bz2 |
Fix nested scrolling bugs in AbsListView
* rawDeltaY should be offset by mMotionCorrection when passing it
to dispatchNestedPreScroll
* mScrollOffset should offset the next motion event, not the current
one
Bug: 14572732
Change-Id: Ib98f27d608b91706af4537e1cf9ad42adce121ea
-rw-r--r-- | core/java/android/widget/AbsListView.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index f4cd5fc..17db689 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -743,7 +743,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te * * @param view The view whose scroll state is being reported * - * @param scrollState The current scroll state. One of + * @param scrollState The current scroll state. One of * {@link #SCROLL_STATE_TOUCH_SCROLL} or {@link #SCROLL_STATE_IDLE}. */ public void onScrollStateChanged(AbsListView view, int scrollState); @@ -3305,18 +3305,22 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te private void scrollIfNeeded(int y, MotionEvent vtev) { int rawDeltaY = y - mMotionY; + int scrollOffsetCorrection = 0; + int scrollConsumedCorrection = 0; + if (mLastY == Integer.MIN_VALUE) { + rawDeltaY -= mMotionCorrection; + } if (dispatchNestedPreScroll(0, rawDeltaY, mScrollConsumed, mScrollOffset)) { rawDeltaY -= mScrollConsumed[1]; - mMotionCorrection -= mScrollOffset[1]; - if (mLastY != Integer.MIN_VALUE) { - mLastY -= mScrollOffset[1] + mScrollConsumed[1]; - } + scrollOffsetCorrection -= mScrollOffset[1]; + scrollConsumedCorrection -= mScrollConsumed[1]; if (vtev != null) { vtev.offsetLocation(0, mScrollOffset[1]); } } - final int deltaY = rawDeltaY - mMotionCorrection; - int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : deltaY; + final int deltaY = rawDeltaY; + int incrementalDeltaY = + mLastY != Integer.MIN_VALUE ? y - mLastY - scrollConsumedCorrection : deltaY; int lastYCorrection = 0; if (mTouchMode == TOUCH_MODE_SCROLL) { @@ -3378,7 +3382,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te (motionViewRealTop - motionViewPrevTop); if (dispatchNestedScroll(0, overscroll - incrementalDeltaY, 0, overscroll, mScrollOffset)) { - mMotionCorrection -= mScrollOffset[1]; lastYCorrection -= mScrollOffset[1]; if (vtev != null) { vtev.offsetLocation(0, mScrollOffset[1]); @@ -3415,9 +3418,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } } } - mMotionY = y; + mMotionY = y + scrollOffsetCorrection; } - mLastY = y + lastYCorrection; + mLastY = y + lastYCorrection + scrollOffsetCorrection; } } else if (mTouchMode == TOUCH_MODE_OVERSCROLL) { if (y != mLastY) { |