mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
优化
This commit is contained in:
parent
c3502fa6ea
commit
8574046f35
@ -1,14 +1,26 @@
|
||||
package io.legado.app.help.coroutine
|
||||
|
||||
import io.legado.app.utils.printOnDebug
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CompletionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.DisposableHandle
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.plus
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
/**
|
||||
* 链式协程
|
||||
*/
|
||||
@Suppress("unused")
|
||||
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||
class Coroutine<T>(
|
||||
val scope: CoroutineScope,
|
||||
context: CoroutineContext = Dispatchers.IO,
|
||||
|
@ -42,11 +42,11 @@ object SharedJsScope {
|
||||
val js = okHttpClient.newCallStrResponse {
|
||||
url(value)
|
||||
}.body
|
||||
it.evaluateString(scope, js, "jsLib", 1, null)
|
||||
evaluateString(scope, js, "jsLib", 1, null)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it.evaluateString(scope, jsLib, "jsLib", 1, null)
|
||||
evaluateString(scope, jsLib, "jsLib", 1, null)
|
||||
}
|
||||
}
|
||||
scopeMap[key] = WeakReference(scope)
|
||||
|
@ -4,7 +4,7 @@ import org.mozilla.javascript.Context
|
||||
|
||||
object Rhino {
|
||||
|
||||
inline fun <R> use(block: (Context) -> R): R {
|
||||
inline fun <R> use(block: Context.() -> R): R {
|
||||
val context = Context.enter()
|
||||
return try {
|
||||
block.invoke(context)
|
||||
|
Loading…
Reference in New Issue
Block a user