epoxy-adapter / com.airbnb.epoxy / EpoxyRecyclerView / setRemoveAdapterWhenDetachedFromWindow

setRemoveAdapterWhenDetachedFromWindow

fun setRemoveAdapterWhenDetachedFromWindow(removeAdapterWhenDetachedFromWindow: Boolean): Unit

If set to true, any adapter set on this recyclerview will be removed when this view is detached from the window. This is useful to prevent leaking a reference to this RecyclerView. This is useful in cases where the same adapter can be used across multiple views (views which can be destroyed and recreated), such as with fragments. In that case the adapter is not necessarily cleared from previous RecyclerViews, so the adapter will continue to hold a reference to those views and leak them. More details at https://github.com/airbnb/epoxy/wiki/Avoiding-Memory-Leaks#parent-view

The default is true, but you can disable this if you don't want your adapter detached automatically.

If the adapter is removed via this setting, it will be re-set on the RecyclerView if the RecyclerView is re-attached to the window at a later point.