Prevent GoneOnInvisibleListener leak

This commit is contained in:
Koitharu
2022-09-12 15:43:42 +03:00
parent 39e574e9dc
commit 2d727a0da8
3 changed files with 21 additions and 4 deletions

View File

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