修复自动换源的bug

pull/370/head
gedoor 4 years ago
parent 63ac140bf2
commit feea86ff14
  1. 23
      app/src/main/java/io/legado/app/service/help/ReadBook.kt

@ -264,8 +264,9 @@ object ReadBook {
private fun download(chapter: BookChapter, resetPageOffset: Boolean) { private fun download(chapter: BookChapter, resetPageOffset: Boolean) {
book?.let { book -> book?.let { book ->
webBook?.getContent(book, chapter) webBook?.let {
?.onSuccess(Dispatchers.IO) { content -> it.getContent(book, chapter)
.onSuccess(Dispatchers.IO) { content ->
if (content.isEmpty()) { if (content.isEmpty()) {
contentLoadFinish( contentLoadFinish(
book, book,
@ -276,10 +277,15 @@ object ReadBook {
removeLoading(chapter.index) removeLoading(chapter.index)
} else { } else {
BookHelp.saveContent(book, chapter, content) BookHelp.saveContent(book, chapter, content)
contentLoadFinish(book, chapter, content, resetPageOffset = resetPageOffset) contentLoadFinish(
book,
chapter,
content,
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index) removeLoading(chapter.index)
} }
}?.onError { }.onError {
contentLoadFinish( contentLoadFinish(
book, book,
chapter, chapter,
@ -288,7 +294,16 @@ object ReadBook {
) )
removeLoading(chapter.index) removeLoading(chapter.index)
} }
} ?: let {
contentLoadFinish(
book,
chapter,
"没有书源",
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index)
} }
} ?: removeLoading(chapter.index)
} }
private fun addLoading(index: Int): Boolean { private fun addLoading(index: Int): Boolean {

Loading…
Cancel
Save