From 5362f62078532e47a5400304553c46731dd64cee Mon Sep 17 00:00:00 2001 From: Samuel Bronson Date: Wed, 18 Sep 2019 13:32:42 -0400 Subject: [PATCH] Update deprecated coroutines code --- .../extension/util/ExtensionInstallReceiver.kt | 5 ++++- .../eu/kanade/tachiyomi/util/CoroutinesExtensions.kt | 11 ++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallReceiver.kt index 5067aa9362..12df620f14 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallReceiver.kt @@ -7,6 +7,9 @@ import android.content.IntentFilter import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.LoadResult import eu.kanade.tachiyomi.util.launchNow +import kotlinx.coroutines.experimental.CoroutineStart +import kotlinx.coroutines.experimental.Dispatchers +import kotlinx.coroutines.experimental.GlobalScope import kotlinx.coroutines.experimental.async /** @@ -91,7 +94,7 @@ internal class ExtensionInstallReceiver(private val listener: Listener) : private suspend fun getExtensionFromIntent(context: Context, intent: Intent?): LoadResult { val pkgName = getPackageNameFromIntent(intent) ?: return LoadResult.Error("Package name not found") - return async { ExtensionLoader.loadExtensionFromPkgName(context, pkgName) }.await() + return GlobalScope.async(Dispatchers.Default, CoroutineStart.DEFAULT, null, { ExtensionLoader.loadExtensionFromPkgName(context, pkgName) }).await() } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/CoroutinesExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/CoroutinesExtensions.kt index 04d55ecdbf..dda2051c17 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/CoroutinesExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/CoroutinesExtensions.kt @@ -1,13 +1,10 @@ package eu.kanade.tachiyomi.util -import kotlinx.coroutines.experimental.CoroutineScope -import kotlinx.coroutines.experimental.CoroutineStart -import kotlinx.coroutines.experimental.Job -import kotlinx.coroutines.experimental.android.UI -import kotlinx.coroutines.experimental.launch +import kotlinx.coroutines.experimental.* +import kotlinx.coroutines.experimental.android.Main fun launchUI(block: suspend CoroutineScope.() -> Unit): Job = - launch(UI, CoroutineStart.DEFAULT, null, null, block) + GlobalScope.launch(Dispatchers.Main, CoroutineStart.DEFAULT, null, block) fun launchNow(block: suspend CoroutineScope.() -> Unit): Job = - launch(UI, CoroutineStart.UNDISPATCHED, null, null, block) + GlobalScope.launch(Dispatchers.Main, CoroutineStart.UNDISPATCHED, null, block)