Fixed fast scroll performance

This commit is contained in:
M66B 2020-01-26 18:53:49 +01:00
parent b6b1768461
commit 7054afec29
1 changed files with 8 additions and 6 deletions

View File

@ -449,12 +449,14 @@ public class FastScrollerEx extends RecyclerView.ItemDecoration implements Recyc
if (Math.abs(mVerticalThumbCenterY - y) < 2) { if (Math.abs(mVerticalThumbCenterY - y) < 2) {
return; return;
} }
int scrollingBy = scrollTo(mVerticalDragY, y, scrollbarRange,
mRecyclerView.computeVerticalScrollRange(), int scrollbarLength = scrollbarRange[1] - scrollbarRange[0];
mRecyclerView.computeVerticalScrollOffset(), mRecyclerViewHeight); float percentage = (scrollbarLength == 0 ? 0 : y / (float) scrollbarLength);
if (scrollingBy != 0) { androidx.recyclerview.widget.RecyclerView.Adapter adapter = mRecyclerView.getAdapter();
mRecyclerView.scrollBy(0, scrollingBy); int count = (adapter == null ? 0 : adapter.getItemCount());
} int pos = Math.round(count * percentage);
mRecyclerView.scrollToPosition(pos);
mVerticalDragY = y; mVerticalDragY = y;
} }