mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -8,9 +8,11 @@ import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
fun <I, O> AppCompatActivity.registerForActivityResult(contract: ActivityResultContract<I, O>): ActivityResultLauncherAwait<I, O> {
|
||||
var cout: CancellableContinuation<O>? = null
|
||||
lateinit var cout: CancellableContinuation<O>
|
||||
val launcher = registerForActivityResult(contract) {
|
||||
cout?.resume(it)
|
||||
if (cout.isActive) {
|
||||
cout.resume(it)
|
||||
}
|
||||
}
|
||||
return object : ActivityResultLauncherAwait<I, O>() {
|
||||
override suspend fun launch(input: I, options: ActivityOptionsCompat?): O {
|
||||
|
||||
Reference in New Issue
Block a user