Glimpse: ThumbnailLayoutManager: Ignore OOB in onLayoutChildren
When the underlying data is changed when the we're trying to layout the children on the RecyclerView we can hit that. TODO: Add proper syncronization and/or switch to ViewModels Change-Id: I174e6c7c3cca2980ced19a424fc2e12372791d88
This commit is contained in:
parent
10a5c8ff04
commit
ad1c6996f5
|
@ -7,6 +7,7 @@ package org.lineageos.glimpse.thumbnail
|
|||
|
||||
import android.content.Context
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.lineageos.glimpse.ext.px
|
||||
|
||||
class ThumbnailLayoutManager(
|
||||
|
@ -17,6 +18,13 @@ class ThumbnailLayoutManager(
|
|||
spanSizeLookup = ThumbnailSpanSizeLookup(adapter, spanCount)
|
||||
}
|
||||
|
||||
override fun onLayoutChildren(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) {
|
||||
try {
|
||||
super.onLayoutChildren(recycler, state)
|
||||
} catch (_: IndexOutOfBoundsException) {
|
||||
}
|
||||
}
|
||||
|
||||
private class ThumbnailSpanSizeLookup(
|
||||
private val adapter: ThumbnailAdapter,
|
||||
private val spanCount: Int,
|
||||
|
|
Loading…
Reference in New Issue