mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 14:11:00 +00:00
Slow down fast scrolling
This commit is contained in:
parent
ca6a716fbe
commit
03823a34ff
1 changed files with 17 additions and 1 deletions
|
@ -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…
Reference in a new issue