Closed Kevinrob closed 2 years ago
HI! Thank you for the pull request :D Sorry it's taken me a bit to get back to you, there's been a lot going on IRL hehe.
I really appreciate you putting this up, but I'd rather not add a guard condition if we don't know how to reproduce the crash. It seems like this is just band-aid-ing and underlying problem, which I'm not comfortable with :/
However, crashes are definitely bad. So if this is giving you a lot of trouble, I'd recommend composing a new LayoutManager that uses the LoopingLayoutManager internally. It would look something like this:
class MyLayoutManager : LayoutManager, RecyclerView.SmoothScroller.ScrollVectorProvider {
private lateinit var loopingLayoutManager : LoopingLayoutManager
public constructor(context: Context, orientation: Int = VERTICAL, reverseLayout: Boolean = false) {
loopingLayoutManager = LoopingLayoutManager(context, orientation, reverseLayout)
}
public constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) {
loopingLayoutManager = LoopingLayoutManager(context, attrs, defStyleAttr, defStyleRes)
}
public override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State) {
if (state.itemCount == 0) return // Guard condition for crash bug
loopingLayoutManager.onLayoutChildren(recycler, state)
}
// Wrap all other public functions you choose to, etc
}
Or if there's a way to reproduce the issue so we can figure out the root cause, then we can investigate to figure out if the guard condition is the right solution, or if there's a bug somewhere else.
But that's just my opinion! I'm happy to discuss more with you. Thank you again so much for putting up this PR, I really appreciate it =)
We will not use this library anymore. So we don't plan to take time for this bug anymore. Thank you for your answer!
:clap: Resolves
[no issue was created] ### :star2: DescriptionWe have some crash about trying to get item
-1
.The adapter goes from a lot of items to 0 and the crash popup sometimes.
I think that this guard clause should protect us from this crash.
:bug: Testing
It's really hard to reproduce this crash. I don't know how we can test it.
:thought_balloon: Other info
full stacktrace: