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

Commit cae7f573 authored by Adam Cohen's avatar Adam Cohen
Browse files

Fix problem with where PagedView could get stuck (issue 11314889)

-> Also a small code cleanup where something was very weird

Change-Id: I3612e1de924a83d1a91b752f3b9e1e239a8db0ea
parent f72693d9
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -151,6 +151,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc

    protected int mTouchState = TOUCH_STATE_REST;
    protected boolean mForceScreenScrolled = false;
    private boolean mScrollAbortedFromIntercept = false;


    protected OnLongClickListener mLongClickListener;

@@ -1374,6 +1376,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
                final boolean finishedScrolling = (mScroller.isFinished() || xDist < mTouchSlop);
                if (finishedScrolling) {
                    mTouchState = TOUCH_STATE_REST;
                    mScrollAbortedFromIntercept = true;
                    abortScrollerAnimation(false);
                } else {
                    if (isTouchPointInViewportWithBuffer((int) mDownMotionX, (int) mDownMotionY)) {
@@ -1401,6 +1404,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc

            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                if (mScrollAbortedFromIntercept) {
                    snapToDestination();
                }
                resetTouchState();
                break;

@@ -1859,15 +1865,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
                        snapToPageWithVelocity(finalPage, velocityX);
                    } else {
                        snapToDestination();
                    }            } else if (mTouchState == TOUCH_STATE_PREV_PAGE) {
                    // at this point we have not moved beyond the touch slop
                    // (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
                    // we can just page
                    int nextPage = Math.max(0, mCurrentPage - 1);
                    if (nextPage != mCurrentPage) {
                        snapToPage(nextPage);
                    } else {
                        snapToDestination();
                    }
                } else {
                    if (!mScroller.isFinished()) {
@@ -1882,6 +1879,16 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
                            getScrollY(), vX, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0);
                    invalidate();
                }
            } else if (mTouchState == TOUCH_STATE_PREV_PAGE) {
                // at this point we have not moved beyond the touch slop
                // (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
                // we can just page
                int nextPage = Math.max(0, mCurrentPage - 1);
                if (nextPage != mCurrentPage) {
                    snapToPage(nextPage);
                } else {
                    snapToDestination();
                }
            } else if (mTouchState == TOUCH_STATE_NEXT_PAGE) {
                // at this point we have not moved beyond the touch slop
                // (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
@@ -1953,6 +1960,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
        releaseVelocityTracker();
        endReordering();
        mCancelTap = false;
        mScrollAbortedFromIntercept = false;
        mTouchState = TOUCH_STATE_REST;
        mActivePointerId = INVALID_POINTER;
    }