Status Update
Comments
xa...@gmail.com <xa...@gmail.com> #2
if (viewSizeOutOfBounds >= 0) {
updatedViewSizeOutOfBounds = (viewSizeOutOfBounds - (recyclerView.paddingBottom*0.7f).toInt()).coerceIn(1, viewSize)
} else {
updatedViewSizeOutOfBounds = (viewSizeOutOfBounds - (recyclerView.paddingTop*0.7f).toInt()).coerceIn(-viewSize, -1)
}
je...@google.com <je...@google.com>
sh...@google.com <sh...@google.com> #3
Sorry for the extreme delay in responding to this bug.
In our experience, it is often too difficult to reproduce bugs based on a description (there are too many factors that we aren't aware of that set up to reproduce the bug). What really helps us fix bugs is when a minimal sample project is provided.
A minimal sample project is a complete Android project that only has the code necessary to demonstrate the bug. Please be sure not to include any third party libraries or extraneous code that makes it harder for us to understand the exact parameters that lead the misbehavior.
Due to the age of this bug (sorry) and the fact there is no sample project, I'm going to close it. However, if this issue still affects you, please file a new bug and attach a minimal sample project that repros it.
Apologies and thanks!
li...@gmail.com <li...@gmail.com> #4
I created a new issue with a sample project.
Description
In the interpolateOutOfBoundsScroll() function in ItemTouchHelper, the viewSizeOutOfBounds value is significantly higher when scrolling up or down if top or bottom padding on the Recyclerview is set. Because of this, sometimes the scroll flies immediately down to the bottom on a Recyclerview with hundreds of rows, or in other cases the scroll is janky and very inconsistent.
I've fixed this issue, and have a much nicer dragging scroll behaviour, with this:
val FULL_SPEED_DELAY = 2400L
val maxSpeed = 20.toDp()
override fun interpolateOutOfBoundsScroll(recyclerView: RecyclerView, viewSize: Int, viewSizeOutOfBounds: Int, totalSize: Int, msSinceStartScroll: Long): Int {
var updatedViewSizeOutOfBounds = 0
if (viewSizeOutOfBounds >= 0) {
updatedViewSizeOutOfBounds = (viewSizeOutOfBounds - (recyclerView.paddingBottom*0.7f).toInt()).coerceIn(1, viewSize)
} else {
updatedViewSizeOutOfBounds = (viewSizeOutOfBounds - (recyclerView.paddingBottom*0.7f).toInt()).coerceIn(-viewSize, -1)
}
val scrollTime = msSinceStartScroll.coerceIn(1000, FULL_SPEED_DELAY)
var timeRatio = 1f
if (scrollTime < FULL_SPEED_DELAY) {
timeRatio = (scrollTime / FULL_SPEED_DELAY.toFloat())
}
val intention = updatedViewSizeOutOfBounds.toFloat() / viewSize
val amount = ((intention * maxSpeed * timeRatio).toInt()).coerceIn(-maxSpeed, maxSpeed)
return amount
}