This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Without sharing ViewPool | Sharing ViewPool | ||
---|---|---|---|
Number of inflation | 95 | 31 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
binding.sessionsRecycler.apply { | |
// ... omittning not related code | |
recycledViewPool = sharedRecycledViewPool | |
(layoutManager as LinearLayoutManager).recycleChildrenOnDetach = true | |
} |