|
|
@ -19,6 +19,8 @@ import kotlinx.coroutines.withContext |
|
|
|
|
|
|
|
|
|
|
|
class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isInitFinish = false |
|
|
|
|
|
|
|
|
|
|
|
fun initData(intent: Intent) { |
|
|
|
fun initData(intent: Intent) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true) |
|
|
|
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true) |
|
|
@ -37,6 +39,7 @@ 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) { |
|
|
|
ReadBook.resetData(book) |
|
|
|
ReadBook.resetData(book) |
|
|
|
|
|
|
|
isInitFinish = true |
|
|
|
val count = App.db.bookChapterDao().getChapterCount(book.bookUrl) |
|
|
|
val count = App.db.bookChapterDao().getChapterCount(book.bookUrl) |
|
|
|
if (count == 0) { |
|
|
|
if (count == 0) { |
|
|
|
if (book.tocUrl.isEmpty()) { |
|
|
|
if (book.tocUrl.isEmpty()) { |
|
|
@ -55,6 +58,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
ReadBook.saveRead() |
|
|
|
ReadBook.saveRead() |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
isInitFinish = true |
|
|
|
ReadBook.titleDate.postValue(book.name) |
|
|
|
ReadBook.titleDate.postValue(book.name) |
|
|
|
if (ReadBook.chapterSize == 0) { |
|
|
|
if (ReadBook.chapterSize == 0) { |
|
|
|
if (book.tocUrl.isEmpty()) { |
|
|
|
if (book.tocUrl.isEmpty()) { |
|
|
|