mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-24 13:48:55 +03:00
Explicitly switch between IO/UI dispatchers when updating list of extensions
Potentially fixes #2566
This commit is contained in:
parent
09891bb0ad
commit
7af075633b
2 changed files with 11 additions and 2 deletions
|
@ -12,7 +12,9 @@ import eu.kanade.tachiyomi.extension.util.ExtensionInstallReceiver
|
|||
import eu.kanade.tachiyomi.extension.util.ExtensionInstaller
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchNow
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import kotlinx.coroutines.async
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
|
@ -144,12 +146,16 @@ class ExtensionManager(
|
|||
* Finds the available extensions in the [api] and updates [availableExtensions].
|
||||
*/
|
||||
fun findAvailableExtensions() {
|
||||
launchNow {
|
||||
availableExtensions = try {
|
||||
launchIO {
|
||||
val extensions: List<Extension.Available> = try {
|
||||
api.findExtensions()
|
||||
} catch (e: Exception) {
|
||||
emptyList()
|
||||
}
|
||||
|
||||
launchUI {
|
||||
availableExtensions = extensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ import kotlinx.coroutines.*
|
|||
fun launchUI(block: suspend CoroutineScope.() -> Unit): Job =
|
||||
GlobalScope.launch(Dispatchers.Main, CoroutineStart.DEFAULT, block)
|
||||
|
||||
fun launchIO(block: suspend CoroutineScope.() -> Unit): Job =
|
||||
GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT, block)
|
||||
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
fun launchNow(block: suspend CoroutineScope.() -> Unit): Job =
|
||||
GlobalScope.launch(Dispatchers.Main, CoroutineStart.UNDISPATCHED, block)
|
||||
|
|
Loading…
Reference in a new issue