Skip to content

Instantly share code, notes, and snippets.

Without sharing ViewPool Sharing ViewPool
Number of inflation 95 31
class InflateCounterGroupAdapter : GroupAdapter<ViewHolder>() {
companion object {
private val count: AtomicInteger = AtomicInteger(0)
}
override fun onCreateViewHolder(parent: ViewGroup, layoutResId: Int): ViewHolder {
Timber.d("Inflate view holder ${count.incrementAndGet()}")
return super.onCreateViewHolder(parent, layoutResId)
}
binding.sessionsRecycler.apply {
// ... omittning not related code
recycledViewPool = sharedRecycledViewPool
(layoutManager as LinearLayoutManager).recycleChildrenOnDetach = true
}