kunfei 4 лет назад
Родитель
Сommit
4cee457074
1 измененных файлов с 6 добавлено и 8 удалено
  1. 6 8
      app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt

+ 6 - 8
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<T>(
     val scope: CoroutineScope,
@@ -146,18 +148,14 @@ class Coroutine<T>(
             } 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) }
             }
         }
     }