Merge pull request #2146 from 821938089/little-fix

优化
pull/2148/head
kunfei 2 years ago committed by GitHub
commit 9958646d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 2
      app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt

@ -98,17 +98,15 @@ object BookHelp {
book: Book,
bookChapter: BookChapter,
content: String
) {
) = coroutineScope {
val awaitList = arrayListOf<Deferred<Unit>>()
content.split("\n").forEach {
val matcher = AppPattern.imgPattern.matcher(it)
if (matcher.find()) {
matcher.group(1)?.let { src ->
val mSrc = NetworkUtils.getAbsoluteURL(bookChapter.url, src)
awaitList.add(coroutineScope {
async {
awaitList.add(async {
saveImage(bookSource, book, mSrc)
}
})
}
}

@ -149,7 +149,7 @@ class Coroutine<T>(
try {
start?.let { dispatchVoidCallback(this, it) }
ensureActive()
val value = executeBlock(scope, context, timeMillis ?: 0L, block)
val value = executeBlock(this, context, timeMillis ?: 0L, block)
ensureActive()
success?.let { dispatchCallback(this, value, it) }
} catch (e: Throwable) {

Loading…
Cancel
Save