pull/32/head
kunfei 5 years ago
parent d48741fb52
commit 5dcdc94cf3
  1. 4
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  2. 2
      app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt

@ -30,8 +30,8 @@ interface BookDao {
@Query("select * from books where bookUrl = :bookUrl") @Query("select * from books where bookUrl = :bookUrl")
fun getBook(bookUrl: String): Book? fun getBook(bookUrl: String): Book?
@Query("select * from books order by durChapterTime desc limit 1") @get:Query("select * from books order by durChapterTime desc limit 1")
fun getLastReadBook(): Book? val lastReadBook: Book?
@get:Query("SELECT bookUrl FROM books") @get:Query("SELECT bookUrl FROM books")
val allBookUrls: List<String> val allBookUrls: List<String>

@ -42,7 +42,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
val book = if (!bookUrl.isNullOrEmpty()) { val book = if (!bookUrl.isNullOrEmpty()) {
App.db.bookDao().getBook(bookUrl) App.db.bookDao().getBook(bookUrl)
} else { } else {
App.db.bookDao().getLastReadBook() App.db.bookDao().lastReadBook
} }
book?.let { book?.let {
durChapterIndex = book.durChapterIndex durChapterIndex = book.durChapterIndex

Loading…
Cancel
Save