Slow down fast scrolling

This commit is contained in:
M66B 2021-07-21 21:26:00 +02:00
parent ca6a716fbe
commit 03823a34ff
1 changed files with 17 additions and 1 deletions

View File

@ -464,12 +464,28 @@ public class FastScrollerEx extends RecyclerView.ItemDecoration implements Recyc
int scrollbarLength = scrollbarRange[1] - scrollbarRange[0];
float percentage = (scrollbarLength == 0 ? 0 : y / (float) scrollbarLength);
int pos = Math.round(count * percentage);
mRecyclerView.scrollToPosition(pos);
scrollTo = pos;
mRecyclerView.removeCallbacks(scroll);
mRecyclerView.postDelayed(scroll, 100);
}
mVerticalDragY = y;
}
private int scrollTo;
private final Runnable scroll = new Runnable() {
@Override
public void run() {
try {
eu.faircode.email.Log.i("Fast scroll to=" + scrollTo);
mRecyclerView.scrollToPosition(scrollTo);
} catch (Throwable ex) {
eu.faircode.email.Log.e(ex);
}
}
};
private void horizontalScrollTo(float x) {
final int[] scrollbarRange = getHorizontalRange();
x = Math.max(scrollbarRange[0], Math.min(scrollbarRange[1], x));