pull/48/head
kunfei 5 years ago
parent b2409a0439
commit bee00cba18
  1. 40
      app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt

@ -26,30 +26,30 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application)
} else { } else {
App.db.bookDao().lastReadBook App.db.bookDao().lastReadBook
} }
} AudioPlay.book?.let { book ->
AudioPlay.book?.let { book -> AudioPlay.titleData.postValue(book.name)
AudioPlay.titleData.postValue(book.name) AudioPlay.coverData.postValue(book.getDisplayCover())
AudioPlay.coverData.postValue(book.getDisplayCover()) AudioPlay.durChapterIndex = book.durChapterIndex
AudioPlay.durChapterIndex = book.durChapterIndex AudioPlay.durPageIndex = book.durChapterPos
AudioPlay.durPageIndex = book.durChapterPos App.db.bookSourceDao().getBookSource(book.origin)?.let {
App.db.bookSourceDao().getBookSource(book.origin)?.let { AudioPlay.webBook = WebBook(it)
AudioPlay.webBook = WebBook(it)
}
val count = App.db.bookChapterDao().getChapterCount(book.bookUrl)
if (count == 0) {
if (book.tocUrl.isEmpty()) {
loadBookInfo(book)
} else {
loadChapterList(book)
} }
} else { val count = App.db.bookChapterDao().getChapterCount(book.bookUrl)
if (AudioPlay.durChapterIndex > count - 1) { if (count == 0) {
AudioPlay.durChapterIndex = count - 1 if (book.tocUrl.isEmpty()) {
loadBookInfo(book)
} else {
loadChapterList(book)
}
} else {
if (AudioPlay.durChapterIndex > count - 1) {
AudioPlay.durChapterIndex = count - 1
}
AudioPlay.chapterSize = count
} }
AudioPlay.chapterSize = count
} }
saveRead()
} }
saveRead()
} }
} }

Loading…
Cancel
Save