Last active
August 21, 2020 22:50
-
-
Save DJDarkByte/bf6c0f0984faf93ba53788ae349c40ca to your computer and use it in GitHub Desktop.
RecyclerView that cleans up it's mess instead of leaking
This file contains hidden or 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 LifecycleRecyclerView @JvmOverloads constructor( | |
| context: Context, | |
| attrs: AttributeSet? = null, | |
| defStyleAttr: Int = 0 | |
| ) : RecyclerView(context, attrs, defStyleAttr), LifecycleObserver { | |
| @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) | |
| private fun onDestroy() { | |
| adapter = null | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment