This commit is contained in:
Horis
2025-01-31 15:51:54 +08:00
parent 3f819e281e
commit fced9a2a66
2 changed files with 7 additions and 3 deletions

View File

@@ -367,6 +367,7 @@ object CacheBook {
downloadFinish(chapter, "获取正文失败\n${it.localizedMessage}", resetPageOffset)
}.onCancel {
onCancel(chapter.index)
downloadFinish(chapter, "download canceled", resetPageOffset, true)
}.onFinally {
postEvent(EventBus.UP_DOWNLOAD, book.bookUrl)
}.start()
@@ -375,12 +376,14 @@ object CacheBook {
private fun downloadFinish(
chapter: BookChapter,
content: String,
resetPageOffset: Boolean = false
resetPageOffset: Boolean = false,
canceled: Boolean = false
) {
if (ReadBook.book?.bookUrl == book.bookUrl) {
ReadBook.contentLoadFinish(
book, chapter, content,
resetPageOffset = resetPageOffset,
canceled = canceled
)
}
}

View File

@@ -562,7 +562,7 @@ object ReadBook : CoroutineScope by MainScope() {
it,
upContent,
resetPageOffset,
success
success = success
)
} ?: download(
downloadScope,
@@ -685,10 +685,11 @@ object ReadBook : CoroutineScope by MainScope() {
content: String,
upContent: Boolean = true,
resetPageOffset: Boolean,
canceled: Boolean = false,
success: (() -> Unit)? = null
) {
removeLoading(chapter.index)
if (chapter.index !in durChapterIndex - 1..durChapterIndex + 1) {
if (canceled || chapter.index !in durChapterIndex - 1..durChapterIndex + 1) {
return
}
Coroutine.async {