Merge remote-tracking branch 'origin/master'

pull/2661/head
kunfei 2 years ago
commit 660d6e213d
  1. 1
      app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt
  4. 6
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt

@ -102,6 +102,7 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification
resource: Bitmap,
transition: Transition<in Bitmap>?
) {
view ?: return
ImageProvider.bitmapLruCache.put(url, resource)
binding.verificationCodeImageView.setImageBitmap(resource)
}

@ -84,7 +84,11 @@ class ExploreShowActivity : VMBaseActivity<ActivityExploreShowBinding, ExploreSh
}
override fun isInBookshelf(name: String, author: String): Boolean {
return viewModel.bookshelf.contains("$name-$author")
return if (author.isNotBlank()) {
viewModel.bookshelf.contains("$name-$author")
} else {
viewModel.bookshelf.any { it.startsWith("$name-") }
}
}
override fun showBookInfo(book: Book) {

@ -150,6 +150,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
bookSource?.let { bookSource ->
WebBook.getBookInfo(this, bookSource, book, canReName = canReName)
.onSuccess(IO) {
appDb.bookDao.getBook(book.name, book.author)?.let {
inBookshelf = true
}
bookData.postValue(book)
if (isImportBookOnLine) {
appDb.searchBookDao.update(book.toSearchBook())

@ -408,7 +408,11 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
* 是否已经加入书架
*/
override fun isInBookshelf(name: String, author: String): Boolean {
return viewModel.bookshelf.contains("$name-$author")
return if (author.isNotBlank()) {
viewModel.bookshelf.contains("$name-$author")
} else {
viewModel.bookshelf.any { it.startsWith("$name-") }
}
}
/**

Loading…
Cancel
Save