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

Commit f2a204e7 authored by Adam Powell's avatar Adam Powell
Browse files

Added proper overscrolling scroll bar behavior to GridView

parent 60d21566
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -1856,8 +1856,11 @@ public class GridView extends AbsListView {
            final int top = view.getTop();
            int height = view.getHeight();
            if (height > 0) {
                final int whichRow = mFirstPosition / mNumColumns;
                return Math.max(whichRow * 100 - (top * 100) / height, 0);
                final int numColumns = mNumColumns;
                final int whichRow = mFirstPosition / numColumns;
                final int rowCount = (mItemCount + numColumns - 1) / numColumns;
                return Math.max(whichRow * 100 - (top * 100) / height +
                        (int) ((float) mScrollY / getHeight() * rowCount * 100), 0);
            }
        }
        return 0;
@@ -1868,7 +1871,12 @@ public class GridView extends AbsListView {
        // TODO: Account for vertical spacing too
        final int numColumns = mNumColumns;
        final int rowCount = (mItemCount + numColumns - 1) / numColumns;
        return Math.max(rowCount * 100, 0);
        int result = Math.max(rowCount * 100, 0);
        if (mScrollY != 0) {
            // Compensate for overscroll
            result += Math.abs((int) ((float) mScrollY / getHeight() * rowCount * 100));
        }
        return result;
    }
}