mirror of
https://github.com/fcitx5-android/fcitx5-android.git
synced 2026-08-02 04:44:35 +08:00
Migrate to suspendCancellableCoroutine
This commit is contained in:
parent
4fcd43610d
commit
e9e5e5b757
@ -8,11 +8,11 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancelChildren
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import java.util.concurrent.ConcurrentLinkedQueue
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
|
||||
class FcitxLifecycleRegistry : FcitxLifecycle {
|
||||
|
||||
@ -138,9 +138,8 @@ private class AtStateHelper(val lifecycle: FcitxLifecycle, val state: FcitxLifec
|
||||
private var continuation: Continuation<Unit>? = null
|
||||
|
||||
suspend fun <T> run(block: suspend CoroutineScope.() -> T): T {
|
||||
suspendCoroutine { continuation = it }
|
||||
suspendCancellableCoroutine { continuation = it }
|
||||
lifecycle.removeObserver(observer)
|
||||
return block(lifecycle.lifecycleScope)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import org.fcitx.fcitx5.android.R
|
||||
import org.fcitx.fcitx5.android.core.CapabilityFlag
|
||||
import org.fcitx.fcitx5.android.core.CapabilityFlags
|
||||
@ -76,13 +77,12 @@ import splitties.views.dsl.core.lParams
|
||||
import splitties.views.dsl.core.matchParent
|
||||
import java.util.concurrent.Executor
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.hypot
|
||||
import kotlin.math.min
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.sin
|
||||
|
||||
class KawaiiBarComponent : UniqueViewComponent<KawaiiBarComponent, FrameLayout>(),
|
||||
@ -538,7 +538,7 @@ class KawaiiBarComponent : UniqueViewComponent<KawaiiBarComponent, FrameLayout>(
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private suspend fun inflateInlineContentView(suggestion: InlineSuggestion): InlineContentView? {
|
||||
return suspendCoroutine { c ->
|
||||
return suspendCancellableCoroutine { c ->
|
||||
// callback view might be null
|
||||
suggestion.inflate(context, suggestionSize, directExecutor) { v ->
|
||||
c.resume(v)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user