pull/1161/head
gedoor 3 years ago
parent 13f32499b4
commit 05cd5e24cd
  1. 14
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -32,12 +32,14 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
fun initData(intent: Intent) { fun initData(intent: Intent) {
execute { execute {
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true) ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
intent.getStringExtra("bookUrl")?.let { val bookUrl = intent.getStringExtra("bookUrl")
appDb.bookDao.getBook(it)?.let { book -> val book = when {
initBook(book) bookUrl.isNullOrEmpty() -> appDb.bookDao.lastReadBook
} else -> appDb.bookDao.getBook(bookUrl)
} ?: appDb.bookDao.lastReadBook?.let { } ?: ReadBook.book
initBook(it) when {
book != null -> initBook(book)
else -> ReadBook.upMsg(context.getString(R.string.no_book))
} }
}.onFinally { }.onFinally {
ReadBook.saveRead() ReadBook.saveRead()

Loading…
Cancel
Save