L4Digital / FastScroll

A ListView-like FastScroller for Android’s RecyclerView.
Apache License 2.0
901 stars 75 forks source link

FastScrollRecyclerView leaks parent view #41

Closed creati8e closed 4 years ago

creati8e commented 5 years ago

device-2019-04-23-115350 To fix crash you need to make following changes:

class FastScrollRecyclerView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : FastScrollRecyclerView(context, attrs, defStyleAttr) {

    override fun onDetachedFromWindow() {
        super.onDetachedFromWindow()
        adapter = null
    }

}
randr0id commented 5 years ago

This should be handled by the same container that owns the Adapter. Most likely in the onDestroy() method of an Activity or Fragment

AndroidDeveloperLB commented 4 years ago

Why is this a leak? The adapter is inside, and the RecyclerView holds it as usual. If the RecyclerView isn't attached, there is no more reference to it, so it can be GC-d , no?