@@ -98,17 +98,15 @@ object BookHelp {
|
|||||||
book: Book,
|
book: Book,
|
||||||
bookChapter: BookChapter,
|
bookChapter: BookChapter,
|
||||||
content: String
|
content: String
|
||||||
) {
|
) = coroutineScope {
|
||||||
val awaitList = arrayListOf<Deferred<Unit>>()
|
val awaitList = arrayListOf<Deferred<Unit>>()
|
||||||
content.split("\n").forEach {
|
content.split("\n").forEach {
|
||||||
val matcher = AppPattern.imgPattern.matcher(it)
|
val matcher = AppPattern.imgPattern.matcher(it)
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
matcher.group(1)?.let { src ->
|
matcher.group(1)?.let { src ->
|
||||||
val mSrc = NetworkUtils.getAbsoluteURL(bookChapter.url, src)
|
val mSrc = NetworkUtils.getAbsoluteURL(bookChapter.url, src)
|
||||||
awaitList.add(coroutineScope {
|
awaitList.add(async {
|
||||||
async {
|
saveImage(bookSource, book, mSrc)
|
||||||
saveImage(bookSource, book, mSrc)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class Coroutine<T>(
|
|||||||
try {
|
try {
|
||||||
start?.let { dispatchVoidCallback(this, it) }
|
start?.let { dispatchVoidCallback(this, it) }
|
||||||
ensureActive()
|
ensureActive()
|
||||||
val value = executeBlock(scope, context, timeMillis ?: 0L, block)
|
val value = executeBlock(this, context, timeMillis ?: 0L, block)
|
||||||
ensureActive()
|
ensureActive()
|
||||||
success?.let { dispatchCallback(this, value, it) }
|
success?.let { dispatchCallback(this, value, it) }
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
|
|||||||
Reference in New Issue
Block a user