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