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

Commit a87f2346 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "More fun with AbsListView smooth scrolling" into jb-dev

parents 3fcf1c85 aadf4fb6
Loading
Loading
Loading
Loading
+39 −19
Original line number Diff line number Diff line
@@ -4009,17 +4009,19 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        void start(final int position) {
            stop();

            final int childCount = getChildCount();
            if (childCount == 0) {
                // Can't scroll without children.
            if (mDataChanged) {
                    // But we might have something in a minute.
                // Wait until we're back in a stable state to try this.
                post(new Runnable() {
                    @Override public void run() {
                        start(position);
                    }
                });
                return;
            }

            final int childCount = getChildCount();
            if (childCount == 0) {
                // Can't scroll without children.
                return;
            }

@@ -4058,17 +4060,19 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                return;
            }

            final int childCount = getChildCount();
            if (childCount == 0) {
                // Can't scroll without children.
            if (mDataChanged) {
                    // But we might have something in a minute.
                // Wait until we're back in a stable state to try this.
                post(new Runnable() {
                    @Override public void run() {
                        start(position, boundPosition);
                    }
                });
                return;
            }

            final int childCount = getChildCount();
            if (childCount == 0) {
                // Can't scroll without children.
                return;
            }

@@ -4129,9 +4133,26 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            startWithOffset(position, offset, SCROLL_DURATION);
        }

        void startWithOffset(int position, int offset, int duration) {
        void startWithOffset(final int position, int offset, final int duration) {
            stop();

            if (mDataChanged) {
                // Wait until we're back in a stable state to try this.
                final int postOffset = offset;
                post(new Runnable() {
                    @Override public void run() {
                        startWithOffset(position, postOffset, duration);
                    }
                });
                return;
            }

            final int childCount = getChildCount();
            if (childCount == 0) {
                // Can't scroll without children.
                return;
            }

            offset += getPaddingTop();

            mTargetPos = position;
@@ -4141,7 +4162,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            mMode = MOVE_OFFSET;

            final int firstPos = mFirstPosition;
            final int childCount = getChildCount();
            final int lastPos = firstPos + childCount - 1;

            int viewTravelCount;
@@ -4514,7 +4534,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te

        if (distance == 0 || mItemCount == 0 || childCount == 0 ||
                (firstPos == 0 && getChildAt(0).getTop() == topLimit && distance < 0) ||
                (lastPos == mItemCount - 1 &&
                (lastPos == mItemCount &&
                        getChildAt(childCount - 1).getBottom() == bottomLimit && distance > 0)) {
            mFlingRunnable.endFling();
            if (mPositionScroller != null) {