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

Commit bbceeffe authored by Adam Powell's avatar Adam Powell Committed by Android Git Automerger
Browse files

am 7c673645: am 76cedc5b: am 0bff30ba: am c8d72a97: Merge "Track persistent...

am 7c673645: am 76cedc5b: am 0bff30ba: am c8d72a97: Merge "Track persistent nested Y offset for fling velocity" into lmp-dev

* commit '7c673645310530dc22ee99719f3538dabbd69a02':
  Track persistent nested Y offset for fling velocity
parents c44c0a52 ef87adb6
Loading
Loading
Loading
Loading
+15 −2
Original line number Original line Diff line number Diff line
@@ -611,6 +611,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    private final int[] mScrollOffset = new int[2];
    private final int[] mScrollOffset = new int[2];
    private final int[] mScrollConsumed = new int[2];
    private final int[] mScrollConsumed = new int[2];


    // Used for offsetting MotionEvents that we feed to the VelocityTracker.
    // In the future it would be nice to be able to give this to the VelocityTracker
    // directly, or alternatively put a VT into absolute-positioning mode that only
    // reads the raw screen-coordinate x/y values.
    private int mNestedYOffset = 0;

    // True when the popup should be hidden because of a call to
    // True when the popup should be hidden because of a call to
    // dispatchDisplayHint()
    // dispatchDisplayHint()
    private boolean mPopupHidden;
    private boolean mPopupHidden;
@@ -3332,6 +3338,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            scrollConsumedCorrection = mScrollConsumed[1];
            scrollConsumedCorrection = mScrollConsumed[1];
            if (vtev != null) {
            if (vtev != null) {
                vtev.offsetLocation(0, mScrollOffset[1]);
                vtev.offsetLocation(0, mScrollOffset[1]);
                mNestedYOffset += mScrollOffset[1];
            }
            }
        }
        }
        final int deltaY = rawDeltaY;
        final int deltaY = rawDeltaY;
@@ -3401,6 +3408,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                            lastYCorrection -= mScrollOffset[1];
                            lastYCorrection -= mScrollOffset[1];
                            if (vtev != null) {
                            if (vtev != null) {
                                vtev.offsetLocation(0, mScrollOffset[1]);
                                vtev.offsetLocation(0, mScrollOffset[1]);
                                mNestedYOffset += mScrollOffset[1];
                            }
                            }
                        } else {
                        } else {
                            final boolean atOverscrollEdge = overScrollBy(0, overscroll,
                            final boolean atOverscrollEdge = overScrollBy(0, overscroll,
@@ -3584,6 +3592,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        final MotionEvent vtev = MotionEvent.obtain(ev);
        final MotionEvent vtev = MotionEvent.obtain(ev);


        final int actionMasked = ev.getActionMasked();
        final int actionMasked = ev.getActionMasked();
        if (actionMasked == MotionEvent.ACTION_DOWN) {
            mNestedYOffset = 0;
        }
        vtev.offsetLocation(0, mNestedYOffset);
        switch (actionMasked) {
        switch (actionMasked) {
            case MotionEvent.ACTION_DOWN: {
            case MotionEvent.ACTION_DOWN: {
                onTouchDown(ev);
                onTouchDown(ev);
@@ -4146,7 +4158,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te


    @Override
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        int action = ev.getAction();
        final int actionMasked = ev.getActionMasked();
        View v;
        View v;


        if (mPositionScroller != null) {
        if (mPositionScroller != null) {
@@ -4165,7 +4177,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            return true;
            return true;
        }
        }


        switch (action & MotionEvent.ACTION_MASK) {
        switch (actionMasked) {
        case MotionEvent.ACTION_DOWN: {
        case MotionEvent.ACTION_DOWN: {
            int touchMode = mTouchMode;
            int touchMode = mTouchMode;
            if (touchMode == TOUCH_MODE_OVERFLING || touchMode == TOUCH_MODE_OVERSCROLL) {
            if (touchMode == TOUCH_MODE_OVERFLING || touchMode == TOUCH_MODE_OVERSCROLL) {
@@ -4192,6 +4204,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            mLastY = Integer.MIN_VALUE;
            mLastY = Integer.MIN_VALUE;
            initOrResetVelocityTracker();
            initOrResetVelocityTracker();
            mVelocityTracker.addMovement(ev);
            mVelocityTracker.addMovement(ev);
            mNestedYOffset = 0;
            startNestedScroll(SCROLL_AXIS_VERTICAL);
            startNestedScroll(SCROLL_AXIS_VERTICAL);
            if (touchMode == TOUCH_MODE_FLING) {
            if (touchMode == TOUCH_MODE_FLING) {
                return true;
                return true;
+11 −2
Original line number Original line Diff line number Diff line
@@ -142,6 +142,7 @@ public class ScrollView extends FrameLayout {
     */
     */
    private final int[] mScrollOffset = new int[2];
    private final int[] mScrollOffset = new int[2];
    private final int[] mScrollConsumed = new int[2];
    private final int[] mScrollConsumed = new int[2];
    private int mNestedYOffset;


    /**
    /**
     * The StrictMode "critical time span" objects to catch animation
     * The StrictMode "critical time span" objects to catch animation
@@ -516,6 +517,7 @@ public class ScrollView extends FrameLayout {
                    mLastMotionY = y;
                    mLastMotionY = y;
                    initVelocityTrackerIfNotExists();
                    initVelocityTrackerIfNotExists();
                    mVelocityTracker.addMovement(ev);
                    mVelocityTracker.addMovement(ev);
                    mNestedYOffset = 0;
                    if (mScrollStrictSpan == null) {
                    if (mScrollStrictSpan == null) {
                        mScrollStrictSpan = StrictMode.enterCriticalSpan("ScrollView-scroll");
                        mScrollStrictSpan = StrictMode.enterCriticalSpan("ScrollView-scroll");
                    }
                    }
@@ -586,9 +588,14 @@ public class ScrollView extends FrameLayout {


        MotionEvent vtev = MotionEvent.obtain(ev);
        MotionEvent vtev = MotionEvent.obtain(ev);


        final int action = ev.getAction();
        final int actionMasked = ev.getActionMasked();


        switch (action & MotionEvent.ACTION_MASK) {
        if (actionMasked == MotionEvent.ACTION_DOWN) {
            mNestedYOffset = 0;
        }
        vtev.offsetLocation(0, mNestedYOffset);

        switch (actionMasked) {
            case MotionEvent.ACTION_DOWN: {
            case MotionEvent.ACTION_DOWN: {
                if (getChildCount() == 0) {
                if (getChildCount() == 0) {
                    return false;
                    return false;
@@ -630,6 +637,7 @@ public class ScrollView extends FrameLayout {
                if (dispatchNestedPreScroll(0, deltaY, mScrollConsumed, mScrollOffset)) {
                if (dispatchNestedPreScroll(0, deltaY, mScrollConsumed, mScrollOffset)) {
                    deltaY -= mScrollConsumed[1];
                    deltaY -= mScrollConsumed[1];
                    vtev.offsetLocation(0, mScrollOffset[1]);
                    vtev.offsetLocation(0, mScrollOffset[1]);
                    mNestedYOffset += mScrollOffset[1];
                }
                }
                if (!mIsBeingDragged && Math.abs(deltaY) > mTouchSlop) {
                if (!mIsBeingDragged && Math.abs(deltaY) > mTouchSlop) {
                    final ViewParent parent = getParent();
                    final ViewParent parent = getParent();
@@ -666,6 +674,7 @@ public class ScrollView extends FrameLayout {
                    if (dispatchNestedScroll(0, scrolledDeltaY, 0, unconsumedY, mScrollOffset)) {
                    if (dispatchNestedScroll(0, scrolledDeltaY, 0, unconsumedY, mScrollOffset)) {
                        mLastMotionY -= mScrollOffset[1];
                        mLastMotionY -= mScrollOffset[1];
                        vtev.offsetLocation(0, mScrollOffset[1]);
                        vtev.offsetLocation(0, mScrollOffset[1]);
                        mNestedYOffset += mScrollOffset[1];
                    } else if (canOverscroll) {
                    } else if (canOverscroll) {
                        final int pulledToY = oldY + deltaY;
                        final int pulledToY = oldY + deltaY;
                        if (pulledToY < 0) {
                        if (pulledToY < 0) {