RecyclerView setRecycledPool and recycleChildrenOnDetach for RecyclerViews in ViewPager2, and inner RecyclerViews

540 views Asked by At

recycleChildrenOnDetach has documentation as

Set whether LayoutManager will recycle its children when it is detached from RecyclerView. If you are using a RecyclerView.RecycledViewPool, it might be a good idea to set this flag to true so that views will be available to other RecyclerViews immediately. Note that, setting this flag will result in a performance drop if RecyclerView is restored.

If this flag is not set scraps in RecycledViewPool be available when onViewRecycled instead of

onViewDetachedFromWindow, right?

What does it mean by performance drop if RecyclerView is restored?

I have 3 fragments as pages of ViewPager2 inside a fragment. Both 3 fragments have a list of same type of layout for RecyclerView rows each getting data from different resources when user swipes to that page, in this situation does it help to share pool and setting recycleChildrenOnDetach to true?

Also in another situation where a vertical RecyclerView hosting multiple horizontal recyclerViews with same layout resource like Play Store app, does it have any impact in this situaton?

0

There are 0 answers