pull/1419/head
gedoor 3 years ago
parent de0cece1a8
commit c4c70fb197
  1. 13
      app/src/main/java/io/legado/app/model/ReadBook.kt
  2. 10
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -52,7 +52,6 @@ object ReadBook : CoroutineScope by MainScope() {
durChapterIndex = book.durChapterIndex durChapterIndex = book.durChapterIndex
durChapterPos = book.durChapterPos durChapterPos = book.durChapterPos
isLocalBook = book.origin == BookType.local isLocalBook = book.origin == BookType.local
chapterSize = book.totalChapterNum
clearTextChapter() clearTextChapter()
callBack?.upMenuView() callBack?.upMenuView()
callBack?.upPageAnim() callBack?.upPageAnim()
@ -63,6 +62,18 @@ object ReadBook : CoroutineScope by MainScope() {
} }
} }
fun upData(book: Book) {
ReadBook.book = book
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
if (durChapterIndex != book.durChapterIndex) {
durChapterIndex = book.durChapterIndex
durChapterPos = book.durChapterPos
clearTextChapter()
}
callBack?.upMenuView()
upWebBook(book)
}
fun upWebBook(book: Book) { fun upWebBook(book: Book) {
if (book.origin == BookType.local) { if (book.origin == BookType.local) {
bookSource = null bookSource = null

@ -68,16 +68,8 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
} }
syncBookProgress(book) syncBookProgress(book)
} else { } else {
ReadBook.book = book ReadBook.upData(book)
if (ReadBook.durChapterIndex != book.durChapterIndex) {
ReadBook.durChapterIndex = book.durChapterIndex
ReadBook.durChapterPos = book.durChapterPos
ReadBook.clearTextChapter()
}
ReadBook.callBack?.upMenuView()
ReadBook.upWebBook(book)
isInitFinish = true isInitFinish = true
ReadBook.chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
if (ReadBook.chapterSize == 0) { if (ReadBook.chapterSize == 0) {
if (book.tocUrl.isEmpty()) { if (book.tocUrl.isEmpty()) {
loadBookInfo(book) loadBookInfo(book)

Loading…
Cancel
Save