Update deprecated coroutines code
This commit is contained in:
parent
ccd360687e
commit
5362f62078
@ -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()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user