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")
fun getBook(bookUrl: String): Book?
@Query("select * from books order by durChapterTime desc limit 1")
fun getLastReadBook(): Book?
@get:Query("select * from books order by durChapterTime desc limit 1")
val lastReadBook: Book?
@get:Query("SELECT bookUrl FROM books")
val allBookUrls: List<String>

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

Loading…
Cancel
Save