现在超时不会触发取消任务了,onFinal会正常触发,取消任务的时候不触发onFinal,防止服务退出后仍然执行onFinal

pull/2121/head
kunfei 2 years ago
parent 97b74d9c98
commit 1bcbae9de7
  1. 6
      app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt

@ -148,7 +148,7 @@ class Coroutine<T>(
success?.let { dispatchCallback(this, value, it) } success?.let { dispatchCallback(this, value, it) }
} catch (e: Throwable) { } catch (e: Throwable) {
e.printOnDebug() e.printOnDebug()
if (e is CancellationException && !isActive && e !is ActivelyCancelException) { if (e is CancellationException && e !is ActivelyCancelException && isCancelled) {
this@Coroutine.cancel() this@Coroutine.cancel()
} }
val consume: Boolean = errorReturn?.value?.let { value -> val consume: Boolean = errorReturn?.value?.let { value ->
@ -159,9 +159,7 @@ class Coroutine<T>(
error?.let { dispatchCallback(this, e, it) } error?.let { dispatchCallback(this, e, it) }
} }
} finally { } finally {
withContext(NonCancellable) { finally?.let { dispatchVoidCallback(this, it) }
finally?.let { dispatchVoidCallback(this, it) }
}
} }
} }
} }

Loading…
Cancel
Save