From 27a79ab4323d6133abf787f5a92da1bb943fa44d Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 14 Feb 2022 16:29:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/coroutine/Coroutine.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt b/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt index 779cf609b..06c02f1a1 100644 --- a/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt +++ b/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt @@ -4,7 +4,9 @@ import kotlinx.coroutines.* import timber.log.Timber import kotlin.coroutines.CoroutineContext - +/** + * 链式协程 + */ @Suppress("unused") class Coroutine( val scope: CoroutineScope, @@ -146,18 +148,14 @@ class Coroutine( } catch (e: Throwable) { Timber.e(e) val consume: Boolean = errorReturn?.value?.let { value -> - if (isActive) { - success?.let { dispatchCallback(this, value, it) } - } + success?.let { dispatchCallback(this, value, it) } true } ?: false - if (!consume && isActive) { + if (!consume) { error?.let { dispatchCallback(this, e, it) } } } finally { - if (isActive) { - finally?.let { dispatchVoidCallback(this, it) } - } + finally?.let { dispatchVoidCallback(this, it) } } } }