Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03365563 authored by Yorke Lee's avatar Yorke Lee Committed by Android (Google) Code Review
Browse files

Merge "Fix nested scrolling bugs in AbsListView"

parents bdad5cb1 43943d8b
Loading
Loading
Loading
Loading
+13 −10
Original line number Original line Diff line number Diff line
@@ -3305,18 +3305,22 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te


    private void scrollIfNeeded(int x, int y, MotionEvent vtev) {
    private void scrollIfNeeded(int x, int y, MotionEvent vtev) {
        int rawDeltaY = y - mMotionY;
        int rawDeltaY = y - mMotionY;
        int scrollOffsetCorrection = 0;
        int scrollConsumedCorrection = 0;
        if (mLastY == Integer.MIN_VALUE) {
            rawDeltaY -= mMotionCorrection;
        }
        if (dispatchNestedPreScroll(0, rawDeltaY, mScrollConsumed, mScrollOffset)) {
        if (dispatchNestedPreScroll(0, rawDeltaY, mScrollConsumed, mScrollOffset)) {
            rawDeltaY -= mScrollConsumed[1];
            rawDeltaY -= mScrollConsumed[1];
            mMotionCorrection -= mScrollOffset[1];
            scrollOffsetCorrection -= mScrollOffset[1];
            if (mLastY != Integer.MIN_VALUE) {
            scrollConsumedCorrection -= mScrollConsumed[1];
                mLastY -= mScrollOffset[1] + mScrollConsumed[1];
            }
            if (vtev != null) {
            if (vtev != null) {
                vtev.offsetLocation(0, mScrollOffset[1]);
                vtev.offsetLocation(0, mScrollOffset[1]);
            }
            }
        }
        }
        final int deltaY = rawDeltaY - mMotionCorrection;
        final int deltaY = rawDeltaY;
        int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : deltaY;
        int incrementalDeltaY =
                mLastY != Integer.MIN_VALUE ? y - mLastY - scrollConsumedCorrection : deltaY;
        int lastYCorrection = 0;
        int lastYCorrection = 0;


        if (mTouchMode == TOUCH_MODE_SCROLL) {
        if (mTouchMode == TOUCH_MODE_SCROLL) {
@@ -3378,7 +3382,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                                (motionViewRealTop - motionViewPrevTop);
                                (motionViewRealTop - motionViewPrevTop);
                        if (dispatchNestedScroll(0, overscroll - incrementalDeltaY, 0, overscroll,
                        if (dispatchNestedScroll(0, overscroll - incrementalDeltaY, 0, overscroll,
                                mScrollOffset)) {
                                mScrollOffset)) {
                            mMotionCorrection -= mScrollOffset[1];
                            lastYCorrection -= mScrollOffset[1];
                            lastYCorrection -= mScrollOffset[1];
                            if (vtev != null) {
                            if (vtev != null) {
                                vtev.offsetLocation(0, mScrollOffset[1]);
                                vtev.offsetLocation(0, mScrollOffset[1]);
@@ -3421,9 +3424,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) {
        } else if (mTouchMode == TOUCH_MODE_OVERSCROLL) {
            if (y != mLastY) {
            if (y != mLastY) {