From ca481c69876248719840d6a52678e073923d1258 Mon Sep 17 00:00:00 2001 From: 821938089 <821938089@qq.com> Date: Wed, 10 Aug 2022 12:16:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a1f1c08cf..16c82fabd 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 @@ -149,7 +149,7 @@ class Coroutine( 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) { From d2385c38eac1d8b43e32250dace31b91ff7a4aa4 Mon Sep 17 00:00:00 2001 From: 821938089 <821938089@qq.com> Date: Wed, 10 Aug 2022 18:49:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/BookHelp.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index e9d371a2d..ac5cac99f 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -98,17 +98,15 @@ object BookHelp { book: Book, bookChapter: BookChapter, content: String - ) { + ) = coroutineScope { val awaitList = arrayListOf>() 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 { - saveImage(bookSource, book, mSrc) - } + awaitList.add(async { + saveImage(bookSource, book, mSrc) }) } }