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

Commit ae316450 authored by Yigit Boyar's avatar Yigit Boyar Committed by Android Git Automerger
Browse files

am 4a7c96d4: am 05041606: am 6cdaab18: Merge "Fix scroll position calculation...

am 4a7c96d4: am 05041606: am 6cdaab18: Merge "Fix scroll position calculation when clipToPadding is false" into lmp-dev

* commit '4a7c96d430afc28c6ac02c60a59cfc91097cafe6':
  Fix scroll position calculation when clipToPadding is false
parents 8bc47ed3 6ec30244
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;