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

Commit 40c6c555 authored by Yigit Boyar's avatar Yigit Boyar
Browse files

Fix scroll position calculation when clipToPadding is false

Bug: 17568582
Change-Id: I904450d62c93105db5c61a071c7816278bb441be
parent 2bc75f08
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -1205,7 +1205,6 @@ class FastScroller {
        if (!hasSections || !mMatchDragPosition) {
            return (float) firstVisibleItem / (totalItemCount - visibleItemCount);
        }

        // Ignore headers.
        firstVisibleItem -= mHeaderCount;
        if (firstVisibleItem < 0) {
@@ -1255,9 +1254,19 @@ class FastScroller {
        // across the last item account for whatever space is remaining.
        if (firstVisibleItem > 0 && firstVisibleItem + visibleItemCount == totalItemCount) {
            final View lastChild = mList.getChildAt(visibleItemCount - 1);
            final float lastItemVisible = (float) (mList.getHeight() - mList.getPaddingBottom()
                    - lastChild.getTop()) / lastChild.getHeight();
            result += (1 - result) * lastItemVisible;
            final int bottomPadding = mList.getPaddingBottom();
            final int maxSize;
            final int currentVisibleSize;
            if (mList.getClipToPadding()) {
                maxSize = lastChild.getHeight();
                currentVisibleSize = mList.getHeight() - bottomPadding - lastChild.getTop();
            } else {
                maxSize = lastChild.getHeight() + bottomPadding;
                currentVisibleSize = mList.getHeight() - lastChild.getTop();
            }
            if (currentVisibleSize > 0 && maxSize > 0) {
                result += (1 - result) * ((float) currentVisibleSize / maxSize );
            }
        }

        return result;