|
|
@ -36,11 +36,15 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
private val loadingLock = "loadingLock" |
|
|
|
private val loadingLock = "loadingLock" |
|
|
|
|
|
|
|
|
|
|
|
fun initData(intent: Intent) { |
|
|
|
fun initData(intent: Intent) { |
|
|
|
|
|
|
|
execute { |
|
|
|
inBookshelf = intent.getBooleanExtra("inBookshelf", true) |
|
|
|
inBookshelf = intent.getBooleanExtra("inBookshelf", true) |
|
|
|
val bookUrl = intent.getStringExtra("bookUrl") |
|
|
|
val bookUrl = intent.getStringExtra("bookUrl") |
|
|
|
if (!bookUrl.isNullOrEmpty()) { |
|
|
|
val book = if (!bookUrl.isNullOrEmpty()) { |
|
|
|
execute { |
|
|
|
App.db.bookDao().getBook(bookUrl) |
|
|
|
App.db.bookDao().getBook(bookUrl)?.let { book -> |
|
|
|
} else { |
|
|
|
|
|
|
|
App.db.bookDao().getLastReadBook() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
book?.let { |
|
|
|
durChapterIndex = book.durChapterIndex |
|
|
|
durChapterIndex = book.durChapterIndex |
|
|
|
durPageIndex = book.durChapterPos |
|
|
|
durPageIndex = book.durChapterPos |
|
|
|
isLocalBook = book.origin == BookType.local |
|
|
|
isLocalBook = book.origin == BookType.local |
|
|
@ -64,8 +68,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
chapterListFinish.postValue(true) |
|
|
|
chapterListFinish.postValue(true) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|