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

Commit ad84e191 authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Improve scrolling cache" into ics

parents 45cf7031 92ce8508
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -567,6 +567,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    private Runnable mClearScrollingCache;
    private int mMinimumVelocity;
    private int mMaximumVelocity;
    private int mDecacheThreshold;
    private float mVelocityScale = 1.0f;

    final boolean[] mIsScrap = new boolean[1];
@@ -786,6 +787,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        mTouchSlop = configuration.getScaledTouchSlop();
        mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
        mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
        mDecacheThreshold = mMaximumVelocity / 2;
        mOverscrollDistance = configuration.getScaledOverscrollDistance();
        mOverflingDistance = configuration.getScaledOverflingDistance();

@@ -3650,7 +3652,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                    // Keep the fling alive a little longer
                    postDelayed(this, FLYWHEEL_TIMEOUT);
                } else {
                    endFling();
                    endFling(false); // Don't disable the scrolling cache right after it was enabled
                    mTouchMode = TOUCH_MODE_SCROLL;
                    reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
                }
@@ -3664,6 +3666,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        }

        void start(int initialVelocity) {
            if (Math.abs(initialVelocity) > mDecacheThreshold) {
                // For long flings, scrolling cache causes stutter, so don't use it
                clearScrollingCache();
            }

            int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
            mLastFlingY = initialY;
            mScroller.fling(0, initialY, 0, initialVelocity,
@@ -3733,12 +3740,17 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        }

        void endFling() {
            endFling(true);
        }

        void endFling(boolean clearCache) {
            mTouchMode = TOUCH_MODE_REST;

            removeCallbacks(this);
            removeCallbacks(mCheckFlywheel);

            reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
            if (clearCache)
                clearScrollingCache();
            mScroller.abortAnimation();