RecycledViewPool

 RecycledViewPool

5f533179da1c82722252cbcb93e7356f?s=128

Moyuru Aizawa

June 28, 2019
Tweet

Transcript

  1. RecycledViewPool @MoyuruAizawa

  2. MoyuruAizawa Moyuru Aizawa
 Software engineer of CATS Div. CyberAgent Inc.

    
 Previously at Pairs Div. Eureka Inc.
  3. Recycler Scrap Heap 3FDZDMFS LayoutManager View View View Recycled ViewPool

    View View View Adapter RecyclerView
  4. Recycler Scrap Heap 3FDZDMFS LayoutManager View View View Recycled ViewPool

    View View View Adapter RecyclerView
  5. Recycler Scrap Heap 3FDZDMFS LayoutManager Recycled ViewPool View View View

    Adapter RecyclerView
  6. Recycler Scrap Heap 3FDZDMFS LayoutManager Recycled ViewPool Adapter RecyclerView

  7. 3FDZDMFE7JFX1PPM Recycled ViewPool

  8. 3FDZDMFE7JFX1PPM Recycled ViewPool RecyclerView RecyclerView RecyclerView

  9. 3FDZDMFE7JFX1PPM Activity

  10. 3FDZDMFE7JFX1PPM Activity Fragment Fragment Fragment

  11. 3FDZDMFE7JFX1PPM Activity Fragment Fragment Fragment Recycler View Recycler View Recycler

    View
  12. 3FDZDMFE7JFX1PPM Activity Fragment Fragment Fragment Recycler View Recycler View Recycler

    View Recycled ViewPool
  13. “To maximize view recycling we share the same view pool

    across all EpoxyRecyclerView instances in the same Activity.” BJSCOCFQPYZ&QPYZ3FDZDMFS7JFX
  14. /BWJHBUJPO

  15. class RecycledViewPoolFactory { private val viewPools = SparseArray<RecycledViewPool>() private fun

    create(lifecycleOwner: LifecycleOwner): RecycledViewPool { viewPools.get(lifecycleOwner.hashCode())?.let { return it } val viewPool = RecycledViewPool() viewPools.put(lifecycleOwner.hashCode(), viewPool) lifecycleOwner.lifecycle .addObserver(LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_DESTROY) { viewPool.clear() viewPools.remove(lifecycleOwner.hashCode()) } }) return viewPool } } 3FDZDMFE7JFX1PPM'BDUPSZ
  16. class RecycledViewPoolFactory { private val viewPools = SparseArray<RecycledViewPool>() private fun

    create(lifecycleOwner: LifecycleOwner): RecycledViewPool { viewPools.get(lifecycleOwner.hashCode())?.let { return it } val viewPool = RecycledViewPool() viewPools.put(lifecycleOwner.hashCode(), viewPool) lifecycleOwner.lifecycle .addObserver(LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_DESTROY) { viewPool.clear() viewPools.remove(lifecycleOwner.hashCode()) } }) return viewPool } } 3FDZDMFE7JFX1PPM'BDUPSZ
  17. class RecycledViewPoolFactory { private val viewPools = SparseArray<RecycledViewPool>() private fun

    create(lifecycleOwner: LifecycleOwner): RecycledViewPool { viewPools.get(lifecycleOwner.hashCode())?.let { return it } val viewPool = RecycledViewPool() viewPools.put(lifecycleOwner.hashCode(), viewPool) lifecycleOwner.lifecycle .addObserver(LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_DESTROY) { viewPool.clear() viewPools.remove(lifecycleOwner.hashCode()) } }) return viewPool } } 3FDZDMFE7JFX1PPM'BDUPSZ
  18. class RecycledViewPoolFactory { private val viewPools = SparseArray<RecycledViewPool>() private fun

    create(lifecycleOwner: LifecycleOwner): RecycledViewPool { viewPools.get(lifecycleOwner.hashCode())?.let { return it } val viewPool = RecycledViewPool() viewPools.put(lifecycleOwner.hashCode(), viewPool) lifecycleOwner.lifecycle .addObserver(LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_DESTROY) { viewPool.clear() viewPools.remove(lifecycleOwner.hashCode()) } }) return viewPool } } 3FDZDMFE7JFX1PPM'BDUPSZ
  19. class RecycledViewPoolFactory { private val viewPools = SparseArray<RecycledViewPool>() private fun

    create(lifecycleOwner: LifecycleOwner): RecycledViewPool { viewPools.get(lifecycleOwner.hashCode())?.let { return it } val viewPool = RecycledViewPool() viewPools.put(lifecycleOwner.hashCode(), viewPool) lifecycleOwner.lifecycle .addObserver(LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_DESTROY) { viewPool.clear() viewPools.remove(lifecycleOwner.hashCode()) } }) return viewPool } } 3FDZDMFE7JFX1PPM'BDUPSZ
  20. class RecycledViewPoolFactory { private val viewPools = SparseArray<RecycledViewPool>() private fun

    create(lifecycleOwner: LifecycleOwner): RecycledViewPool { viewPools.get(lifecycleOwner.hashCode())?.let { return it } val viewPool = RecycledViewPool() viewPools.put(lifecycleOwner.hashCode(), viewPool) lifecycleOwner.lifecycle .addObserver(LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_DESTROY) { viewPool.clear() viewPools.remove(lifecycleOwner.hashCode()) } }) return viewPool } } 3FDZDMFE7JFX1PPM'BDUPSZ
  21. class RecycledViewPoolFactory { private val viewPools = SparseArray<RecycledViewPool>() private fun

    create(lifecycleOwner: LifecycleOwner): RecycledViewPool { viewPools.get(lifecycleOwner.hashCode())?.let { return it } val viewPool = RecycledViewPool() viewPools.put(lifecycleOwner.hashCode(), viewPool) lifecycleOwner.lifecycle .addObserver(LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_DESTROY) { viewPool.clear() viewPools.remove(lifecycleOwner.hashCode()) } }) return viewPool } } 3FDZDMFE7JFX1PPM'BDUPSZ
  22. Thank you