Fix crash if adapter is empty.

"java.lang.IndexOutOfBoundsException: Invalid item position -1(-1). Item count:0"
This commit is contained in:
Özcan Kaymak
2018-08-29 11:17:04 +02:00
parent da9fbb3106
commit 2aa6d64a81

View File

@ -278,6 +278,10 @@ class StackLayoutManager(scrollOrientation: ScrollOrientation,
}
override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State) {
if (itemCount == 0) {
return
}
mLayout?.requestLayout()
removeAndRecycleAllViews(recycler)