avoid unnecessary recyclerview.scrollby calls at the fastscroller

This commit is contained in:
tibbi 2021-04-18 21:15:17 +02:00
parent c9c5682bc1
commit 4c93c0a510

View file

@ -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