修复自动换源的bug

pull/370/head
gedoor 4 years ago
parent feea86ff14
commit 01ce78cc5f
  1. 70
      app/src/main/java/io/legado/app/service/help/ReadBook.kt

@ -263,47 +263,49 @@ object ReadBook {
}
private fun download(chapter: BookChapter, resetPageOffset: Boolean) {
book?.let { book ->
webBook?.let {
it.getContent(book, chapter)
.onSuccess(Dispatchers.IO) { content ->
if (content.isEmpty()) {
contentLoadFinish(
book,
chapter,
App.INSTANCE.getString(R.string.content_empty),
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index)
} else {
BookHelp.saveContent(book, chapter, content)
contentLoadFinish(
book,
chapter,
content,
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index)
}
}.onError {
val book = book
val webBook = webBook
if (book != null && webBook != null) {
webBook.getContent(book, chapter)
.onSuccess(Dispatchers.IO) { content ->
if (content.isEmpty()) {
contentLoadFinish(
book,
chapter,
App.INSTANCE.getString(R.string.content_empty),
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index)
} else {
BookHelp.saveContent(book, chapter, content)
contentLoadFinish(
book,
chapter,
it.localizedMessage ?: "未知错误",
content,
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index)
}
} ?: let {
contentLoadFinish(
book,
chapter,
"没有书源",
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index)
}
} ?: removeLoading(chapter.index)
}.onError {
contentLoadFinish(
book,
chapter,
it.localizedMessage ?: "未知错误",
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index)
}
} else if (book != null) {
contentLoadFinish(
book,
chapter,
"没有书源",
resetPageOffset = resetPageOffset
)
removeLoading(chapter.index)
} else {
removeLoading(chapter.index)
}
}
private fun addLoading(index: Int): Boolean {

Loading…
Cancel
Save