pull/1470/head
gedoor 3 years ago
parent f8906cc9dd
commit c8bd22eb1e
  1. 7
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt

@ -35,14 +35,19 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
execute { execute {
val name = intent.getStringExtra("name") ?: "" val name = intent.getStringExtra("name") ?: ""
val author = intent.getStringExtra("author") ?: "" val author = intent.getStringExtra("author") ?: ""
val bookUrl = intent.getStringExtra("bookUrl") ?: ""
appDb.bookDao.getBook(name, author)?.let { book -> appDb.bookDao.getBook(name, author)?.let { book ->
inBookshelf = true inBookshelf = true
setBook(book) setBook(book)
} ?: appDb.searchBookDao.getFirstByNameAuthor(name, author)?.toBook()?.let { book -> } ?: let {
val searchBook = appDb.searchBookDao.getSearchBook(bookUrl)
?: appDb.searchBookDao.getFirstByNameAuthor(name, author)
searchBook?.toBook()?.let { book ->
setBook(book) setBook(book)
} }
} }
} }
}
fun refreshData(intent: Intent) { fun refreshData(intent: Intent) {
execute { execute {

Loading…
Cancel
Save