|
|
@ -47,7 +47,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
|
|
private fun initBook(book: Book) { |
|
|
|
private fun initBook(book: Book) { |
|
|
|
if (ReadBook.book?.bookUrl != book.bookUrl) { |
|
|
|
if (ReadBook.book?.bookUrl != book.bookUrl) { |
|
|
|
downloadProgress(book) |
|
|
|
|
|
|
|
ReadBook.resetData(book) |
|
|
|
ReadBook.resetData(book) |
|
|
|
isInitFinish = true |
|
|
|
isInitFinish = true |
|
|
|
if (!book.isLocalBook() && ReadBook.webBook == null) { |
|
|
|
if (!book.isLocalBook() && ReadBook.webBook == null) { |
|
|
@ -67,6 +66,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
ReadBook.loadContent(resetPageOffset = true) |
|
|
|
ReadBook.loadContent(resetPageOffset = true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
syncBookProgress(book) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ReadBook.book = book |
|
|
|
ReadBook.book = book |
|
|
|
if (ReadBook.durChapterIndex != book.durChapterIndex) { |
|
|
|
if (ReadBook.durChapterIndex != book.durChapterIndex) { |
|
|
@ -100,15 +100,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun downloadProgress(book: Book) { |
|
|
|
|
|
|
|
BookWebDav.getBookProgress(book)?.let { |
|
|
|
|
|
|
|
book.durChapterIndex = it.durChapterIndex |
|
|
|
|
|
|
|
book.durChapterPos = it.durChapterPos |
|
|
|
|
|
|
|
book.durChapterTime = it.durChapterTime |
|
|
|
|
|
|
|
book.durChapterTitle = it.durChapterTitle |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun loadBookInfo( |
|
|
|
private fun loadBookInfo( |
|
|
|
book: Book, |
|
|
|
book: Book, |
|
|
|
changeDruChapterIndex: ((chapters: List<BookChapter>) -> Unit)? = null, |
|
|
|
changeDruChapterIndex: ((chapters: List<BookChapter>) -> Unit)? = null, |
|
|
@ -168,12 +159,14 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
|
|
fun syncBookProgress(book: Book) { |
|
|
|
fun syncBookProgress(book: Book) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
downloadProgress(book) |
|
|
|
BookWebDav.getBookProgress(book)?.let { |
|
|
|
ReadBook.durChapterIndex = book.durChapterIndex |
|
|
|
book.durChapterIndex = it.durChapterIndex |
|
|
|
ReadBook.durChapterPos = book.durChapterPos |
|
|
|
book.durChapterPos = it.durChapterPos |
|
|
|
ReadBook.prevTextChapter = null |
|
|
|
book.durChapterTime = it.durChapterTime |
|
|
|
ReadBook.clearTextChapter() |
|
|
|
book.durChapterTitle = it.durChapterTitle |
|
|
|
ReadBook.loadContent(resetPageOffset = true) |
|
|
|
ReadBook.clearTextChapter() |
|
|
|
|
|
|
|
ReadBook.loadContent(resetPageOffset = true) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|