Address coroutine scope leaks in custom views
This commit is contained in:
@@ -97,7 +97,7 @@ class LibraryAdapter(private val controller: LibraryController) : RecyclerViewPa
|
||||
fun onDestroy() {
|
||||
for (view in boundViews) {
|
||||
if (view is LibraryCategoryView) {
|
||||
view.unsubscribe()
|
||||
view.onDestroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.inflate
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import reactivecircus.flowbinding.recyclerview.scrollStateChanges
|
||||
@@ -155,7 +156,12 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
unsubscribe()
|
||||
}
|
||||
|
||||
fun unsubscribe() {
|
||||
fun onDestroy() {
|
||||
unsubscribe()
|
||||
scope.cancel()
|
||||
}
|
||||
|
||||
private fun unsubscribe() {
|
||||
subscriptions.clear()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user