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) {
return;
}
int scrollingBy = scrollTo(mVerticalDragY, y, scrollbarRange,
mRecyclerView.computeVerticalScrollRange(),
mRecyclerView.computeVerticalScrollOffset(), mRecyclerViewHeight);
if (scrollingBy != 0) {
mRecyclerView.scrollBy(0, scrollingBy);
}
int scrollbarLength = scrollbarRange[1] - scrollbarRange[0];
float percentage = (scrollbarLength == 0 ? 0 : y / (float) scrollbarLength);
androidx.recyclerview.widget.RecyclerView.Adapter adapter = mRecyclerView.getAdapter();
int count = (adapter == null ? 0 : adapter.getItemCount());
int pos = Math.round(count * percentage);
mRecyclerView.scrollToPosition(pos);
mVerticalDragY = y;
}