From 4c93c0a510f06f878cdc0f4b40d769d9d383dd03 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 18 Apr 2021 21:15:17 +0200 Subject: [PATCH] avoid unnecessary recyclerview.scrollby calls at the fastscroller --- .../simplemobiletools/commons/views/FastScroller.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/views/FastScroller.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/views/FastScroller.kt index 6869c5a15..ef4f832b4 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/views/FastScroller.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/views/FastScroller.kt @@ -298,14 +298,20 @@ class FastScroller : FrameLayout { val movePercent = diffInMove / (recyclerViewWidth.toFloat() - handleWidth) val target = (recyclerViewContentWidth - recyclerViewWidth) * movePercent val diff = target.toInt() - currScrollX - recyclerView!!.scrollBy(diff, 0) + + if (diff != 0) { + recyclerView!!.scrollBy(diff, 0) + } } else { targetProportion = currScrollY / recyclerViewContentHeight.toFloat() val diffInMove = pos - handleYOffset val movePercent = diffInMove / (recyclerViewHeight.toFloat() - handleHeight) val target = (recyclerViewContentHeight - recyclerViewHeight) * movePercent val diff = target.toInt() - currScrollY - recyclerView!!.scrollBy(0, diff) + + if (diff != 0) { + recyclerView!!.scrollBy(0, diff) + } } val itemCount = recyclerView!!.adapter!!.itemCount