Update deprecated coroutines code

This commit is contained in:
Samuel Bronson 2019-09-18 13:32:42 -04:00
parent ccd360687e
commit 5362f62078
2 changed files with 8 additions and 8 deletions

View file

@ -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()
}
/**

View file

@ -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)