Slow down fast scrolling

pull/200/head
M66B 4 years ago
parent ca6a716fbe
commit 03823a34ff

@ -464,12 +464,28 @@ public class FastScrollerEx extends RecyclerView.ItemDecoration implements Recyc
int scrollbarLength = scrollbarRange[1] - scrollbarRange[0]; int scrollbarLength = scrollbarRange[1] - scrollbarRange[0];
float percentage = (scrollbarLength == 0 ? 0 : y / (float) scrollbarLength); float percentage = (scrollbarLength == 0 ? 0 : y / (float) scrollbarLength);
int pos = Math.round(count * percentage); int pos = Math.round(count * percentage);
mRecyclerView.scrollToPosition(pos); scrollTo = pos;
mRecyclerView.removeCallbacks(scroll);
mRecyclerView.postDelayed(scroll, 100);
} }
mVerticalDragY = y; 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) { private void horizontalScrollTo(float x) {
final int[] scrollbarRange = getHorizontalRange(); final int[] scrollbarRange = getHorizontalRange();
x = Math.max(scrollbarRange[0], Math.min(scrollbarRange[1], x)); x = Math.max(scrollbarRange[0], Math.min(scrollbarRange[1], x));

Loading…
Cancel
Save