优化
This commit is contained in:
@@ -367,6 +367,7 @@ object CacheBook {
|
|||||||
downloadFinish(chapter, "获取正文失败\n${it.localizedMessage}", resetPageOffset)
|
downloadFinish(chapter, "获取正文失败\n${it.localizedMessage}", resetPageOffset)
|
||||||
}.onCancel {
|
}.onCancel {
|
||||||
onCancel(chapter.index)
|
onCancel(chapter.index)
|
||||||
|
downloadFinish(chapter, "download canceled", resetPageOffset, true)
|
||||||
}.onFinally {
|
}.onFinally {
|
||||||
postEvent(EventBus.UP_DOWNLOAD, book.bookUrl)
|
postEvent(EventBus.UP_DOWNLOAD, book.bookUrl)
|
||||||
}.start()
|
}.start()
|
||||||
@@ -375,12 +376,14 @@ object CacheBook {
|
|||||||
private fun downloadFinish(
|
private fun downloadFinish(
|
||||||
chapter: BookChapter,
|
chapter: BookChapter,
|
||||||
content: String,
|
content: String,
|
||||||
resetPageOffset: Boolean = false
|
resetPageOffset: Boolean = false,
|
||||||
|
canceled: Boolean = false
|
||||||
) {
|
) {
|
||||||
if (ReadBook.book?.bookUrl == book.bookUrl) {
|
if (ReadBook.book?.bookUrl == book.bookUrl) {
|
||||||
ReadBook.contentLoadFinish(
|
ReadBook.contentLoadFinish(
|
||||||
book, chapter, content,
|
book, chapter, content,
|
||||||
resetPageOffset = resetPageOffset,
|
resetPageOffset = resetPageOffset,
|
||||||
|
canceled = canceled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -562,7 +562,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
it,
|
it,
|
||||||
upContent,
|
upContent,
|
||||||
resetPageOffset,
|
resetPageOffset,
|
||||||
success
|
success = success
|
||||||
)
|
)
|
||||||
} ?: download(
|
} ?: download(
|
||||||
downloadScope,
|
downloadScope,
|
||||||
@@ -685,10 +685,11 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
content: String,
|
content: String,
|
||||||
upContent: Boolean = true,
|
upContent: Boolean = true,
|
||||||
resetPageOffset: Boolean,
|
resetPageOffset: Boolean,
|
||||||
|
canceled: Boolean = false,
|
||||||
success: (() -> Unit)? = null
|
success: (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
removeLoading(chapter.index)
|
removeLoading(chapter.index)
|
||||||
if (chapter.index !in durChapterIndex - 1..durChapterIndex + 1) {
|
if (canceled || chapter.index !in durChapterIndex - 1..durChapterIndex + 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Coroutine.async {
|
Coroutine.async {
|
||||||
|
|||||||
Reference in New Issue
Block a user