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

Commit 9413b245 authored by Adam Powell's avatar Adam Powell
Browse files

Nested pre-fling for AbsListView and ScrollView

Add nested pre-fling support to all framework widgets that currently
support nested fling.

Change-Id: Ieaf9d12938dbfeea779c2aee2f5a081c287c8e96
parent 579befec
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -3857,13 +3857,17 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                                    firstChildTop == contentTop - mOverscrollDistance) ||
                              (mFirstPosition + childCount == mItemCount &&
                                    lastChildBottom == contentBottom + mOverscrollDistance))) {
                        if (!dispatchNestedPreFling(0, -initialVelocity)) {
                            if (mFlingRunnable == null) {
                                mFlingRunnable = new FlingRunnable();
                            }
                            reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);

                            mFlingRunnable.start(-initialVelocity);
                            dispatchNestedFling(0, -initialVelocity, true);
                        } else {
                            mTouchMode = TOUCH_MODE_REST;
                            reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
                        }
                    } else {
                        mTouchMode = TOUCH_MODE_REST;
                        reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
@@ -4029,7 +4033,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            if (mFlingRunnable == null) {
                mFlingRunnable = new FlingRunnable();
            }
            if (!dispatchNestedPreFling(0, velocityY)) {
                mFlingRunnable.start((int) velocityY);
            }
            return true;
        }
        return dispatchNestedFling(velocityX, velocityY, consumed);
+5 −3
Original line number Diff line number Diff line
@@ -1577,11 +1577,13 @@ public class ScrollView extends FrameLayout {
    private void flingWithNestedDispatch(int velocityY) {
        final boolean canFling = (mScrollY > 0 || velocityY > 0) &&
                (mScrollY < getScrollRange() || velocityY < 0);
        if (!dispatchNestedPreFling(0, velocityY)) {
            dispatchNestedFling(0, velocityY, canFling);
            if (canFling) {
                fling(velocityY);
            }
        }
    }

    private void endDrag() {
        mIsBeingDragged = false;