pull/475/head
gedoor 4 years ago
parent d8867c9cac
commit bd599d6ca9
  1. 14
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -282,10 +282,12 @@ class AudioPlayService : BaseService(),
} }
} }
private fun loadContent(chapter: BookChapter) = AudioPlay.apply { private fun loadContent(chapter: BookChapter) {
book?.let { book -> val book = AudioPlay.book
webBook?.getContent(book, chapter, scope = this@AudioPlayService) val webBook = AudioPlay.webBook
?.onSuccess { content -> if (book != null && webBook != null) {
webBook.getContent(book, chapter, scope = this@AudioPlayService)
.onSuccess { content ->
removeLoading(chapter.index) removeLoading(chapter.index)
if (content.isEmpty()) { if (content.isEmpty()) {
withContext(Main) { withContext(Main) {
@ -294,10 +296,12 @@ class AudioPlayService : BaseService(),
} else { } else {
contentLoadFinish(chapter, content) contentLoadFinish(chapter, content)
} }
}?.onError { }.onError {
contentLoadFinish(chapter, it.localizedMessage ?: toString()) contentLoadFinish(chapter, it.localizedMessage ?: toString())
removeLoading(chapter.index) removeLoading(chapter.index)
} }
} else {
toast("book or source is null")
} }
} }

Loading…
Cancel
Save