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

Commit 84222e04 authored by Adam Powell's avatar Adam Powell
Browse files

Fix overscroll distance calculation for stack-from-bottom ListViews

Change-Id: Ic8278763586d03c152f7b30b7fdd0b37b0dfc9cb
parent b51132cb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -381,12 +381,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    /**
     * Maximum distance to overscroll by
     */
    private int mOverscrollMax;
    int mOverscrollMax;
    
    /**
     * Content height divided by this is the overscroll limit.
     */
    private static final int OVERSCROLL_LIMIT_DIVISOR = 3;
    static final int OVERSCROLL_LIMIT_DIVISOR = 3;

    /**
     * Used to request a layout when we changed touch mode
@@ -2390,7 +2390,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        awakenScrollBars();
    }
    
    private int getOverscrollMax() {
    int getOverscrollMax() {
        final int childCount = getChildCount();
        if (childCount > 0) {
            return Math.min(mOverscrollMax,
+27 −4
Original line number Diff line number Diff line
@@ -1250,12 +1250,21 @@ public class ListView extends AbsListView {
    int findMotionRow(int y) {
        int childCount = getChildCount();
        if (childCount > 0) {
            if (!mStackFromBottom) {
                for (int i = 0; i < childCount; i++) {
                    View v = getChildAt(i);
                    if (y <= v.getBottom()) {
                        return mFirstPosition + i;
                    }
                }
            } else {
                for (int i = childCount - 1; i >= 0; i--) {
                    View v = getChildAt(i);
                    if (y >= v.getTop()) {
                        return mFirstPosition + i;
                    }
                }
            }
        }
        return INVALID_POSITION;
    }
@@ -3683,6 +3692,20 @@ public class ListView extends AbsListView {
        }
    }
    
    @Override
    int getOverscrollMax() {
        if (mStackFromBottom) {
            final int childCount = getChildCount();
            if (childCount > 0) {
                return Math.min(mOverscrollMax,
                        (getHeight() - getChildAt(0).getTop()) / OVERSCROLL_LIMIT_DIVISOR);
            } else {
                return mOverscrollMax;
            }
        }
        return super.getOverscrollMax();
    }

    static class SavedState extends BaseSavedState {
        SparseBooleanArray checkState;
        LongSparseArray<Boolean> checkIdState;