Prevent GoneOnInvisibleListener leak

This commit is contained in:
Koitharu
2022-09-12 15:43:42 +03:00
parent 757e33dfb4
commit 4186c36f30
4 changed files with 40 additions and 8 deletions

View File

@@ -19,5 +19,10 @@ class GoneOnInvisibleListener(
fun attach() {
view.viewTreeObserver.addOnGlobalLayoutListener(this)
onGlobalLayout()
}
}
fun detach() {
view.viewTreeObserver.removeOnGlobalLayoutListener(this)
}
}