Search in the regular coroutine scope instead of a custom one
This commit is contained in:
parent
18f02a85ac
commit
cf1ce9e069
@ -24,9 +24,7 @@ import eu.kanade.tachiyomi.util.view.inflate
|
|||||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||||
import exh.ui.LoadingHandle
|
import exh.ui.LoadingHandle
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
import kotlinx.coroutines.SupervisorJob
|
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@ -87,11 +85,6 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
|
|
||||||
// EXH -->
|
// EXH -->
|
||||||
private var initialLoadHandle: LoadingHandle? = null
|
private var initialLoadHandle: LoadingHandle? = null
|
||||||
private lateinit var supervisorScope: CoroutineScope
|
|
||||||
|
|
||||||
private fun newScope() = object : CoroutineScope {
|
|
||||||
override val coroutineContext = SupervisorJob() + Dispatchers.Main
|
|
||||||
}
|
|
||||||
// EXH <--
|
// EXH <--
|
||||||
|
|
||||||
fun onCreate(controller: LibraryController, binding: LibraryCategoryBinding) {
|
fun onCreate(controller: LibraryController, binding: LibraryCategoryBinding) {
|
||||||
@ -163,7 +156,6 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
// EXH -->
|
// EXH -->
|
||||||
supervisorScope = newScope()
|
|
||||||
initialLoadHandle = controller.loaderManager.openProgressBar()
|
initialLoadHandle = controller.loaderManager.openProgressBar()
|
||||||
// EXH <--
|
// EXH <--
|
||||||
|
|
||||||
@ -174,7 +166,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe {
|
.subscribe {
|
||||||
// EXH -->
|
// EXH -->
|
||||||
supervisorScope.launch {
|
scope.launch {
|
||||||
val handle = controller.loaderManager.openProgressBar()
|
val handle = controller.loaderManager.openProgressBar()
|
||||||
try {
|
try {
|
||||||
// EXH <--
|
// EXH <--
|
||||||
@ -190,7 +182,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
subscriptions += controller.libraryMangaRelay
|
subscriptions += controller.libraryMangaRelay
|
||||||
.subscribe {
|
.subscribe {
|
||||||
// EXH -->
|
// EXH -->
|
||||||
supervisorScope.launch {
|
scope.launch {
|
||||||
try {
|
try {
|
||||||
// EXH <--
|
// EXH <--
|
||||||
onNextLibraryManga(this, it)
|
onNextLibraryManga(this, it)
|
||||||
@ -235,14 +227,13 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
fun onDestroy() {
|
fun onDestroy() {
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
scope.cancel()
|
scope.cancel()
|
||||||
|
// SY -->
|
||||||
|
controller.loaderManager.closeProgressBar(initialLoadHandle)
|
||||||
|
// SY <--
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun unsubscribe() {
|
private fun unsubscribe() {
|
||||||
subscriptions.clear()
|
subscriptions.clear()
|
||||||
// EXH -->
|
|
||||||
supervisorScope.cancel()
|
|
||||||
controller.loaderManager.closeProgressBar(initialLoadHandle)
|
|
||||||
// EXH <--
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user