diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 37d8c6d3f..6b0e5433f 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -147,7 +147,7 @@ class BookInfoActivity : } private fun showCover(book: Book) { - iv_cover.load(book.getDisplayCover(), book.name) + iv_cover.load(book.getDisplayCover(), book.name, book.author) ImageLoader.load(this, book.getDisplayCover()) .transition(DrawableTransitionOptions.withCrossFade(1500)) .thumbnail(defaultCover()) diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index 9f7b387f2..6bcae9257 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -59,7 +59,7 @@ class BookInfoEditActivity : private fun upCover() { viewModel.book.let { - iv_cover.load(it?.getDisplayCover(), it?.name) + iv_cover.load(it?.getDisplayCover(), it?.name, it?.author) } } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt index 49127927f..4a725e854 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt @@ -67,7 +67,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) : } } } - iv_cover.load(searchBook.coverUrl, searchBook.name) + iv_cover.load(searchBook.coverUrl, searchBook.name, searchBook.author) onClick { callBack.showBookInfo(searchBook.name, searchBook.author) } diff --git a/app/src/main/java/io/legado/app/ui/changecover/CoverAdapter.kt b/app/src/main/java/io/legado/app/ui/changecover/CoverAdapter.kt index e6934675d..a26c21f57 100644 --- a/app/src/main/java/io/legado/app/ui/changecover/CoverAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/changecover/CoverAdapter.kt @@ -13,7 +13,7 @@ class CoverAdapter(context: Context, val callBack: CallBack) : override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList) { with(holder.itemView) { - iv_cover.load(item.coverUrl, item.name) + iv_cover.load(item.coverUrl, item.name, item.author) tv_source.text = item.originName onClick { callBack.changeTo(item.coverUrl!!) diff --git a/app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt b/app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt index 9afad2422..8e2fcf5e8 100644 --- a/app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt @@ -57,7 +57,7 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) : } } } - iv_cover.load(item.coverUrl, item.name) + iv_cover.load(item.coverUrl, item.name, item.author) onClick { callBack.showBookInfo(item.toBook()) } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt index 5cc19d9fc..ffb608f4f 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt @@ -20,7 +20,7 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) : ATH.applyBackgroundTint(this) tv_name.text = item.name bv_author.text = item.author - iv_cover.load(item.getDisplayCover(), item.name) + iv_cover.load(item.getDisplayCover(), item.name, item.author) onClick { callBack.open(item) } onLongClick { callBack.openBookInfo(item) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt index 948b9128e..71b70f0c2 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt @@ -22,7 +22,7 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) : tv_author.text = item.author tv_read.text = item.durChapterTitle tv_last.text = item.latestChapterTitle - iv_cover.load(item.getDisplayCover(), item.name) + iv_cover.load(item.getDisplayCover(), item.name, item.author) onClick { callBack.open(item) } onLongClick { callBack.openBookInfo(item) diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt index 06cefd274..2f7bfb74e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt @@ -20,6 +20,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { private val textPaint = TextPaint() private var name: String? = null + private var author: String? = null constructor(context: Context) : super(context) @@ -81,8 +82,9 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { } } - fun setName(name: String?) { + fun setName(name: String?, author: String?) { this.name = name + this.author = author invalidate() } @@ -91,38 +93,34 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { minimumWidth = width } - fun load(path: String?, name: String?) { - if (path.isNullOrEmpty()) { - setName(name) - } else { - ImageLoader.load(context, path)//Glide自动识别http://和file:// - .placeholder(R.drawable.image_cover_default) - .error(R.drawable.image_cover_default) - .listener(object : RequestListener { - override fun onLoadFailed( - e: GlideException?, - model: Any?, - target: Target?, - isFirstResource: Boolean - ): Boolean { - setName(name) - return false - } - - override fun onResourceReady( - resource: Drawable?, - model: Any?, - target: Target?, - dataSource: DataSource?, - isFirstResource: Boolean - ): Boolean { - setName(null) - return false - } - - }) - .centerCrop() - .into(this) - } + fun load(path: String?, name: String?, author: String?) { + ImageLoader.load(context, path)//Glide自动识别http://和file:// + .placeholder(R.drawable.image_cover_default) + .error(R.drawable.image_cover_default) + .listener(object : RequestListener { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { + setName(name, author) + return false + } + + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { + setName(null, null) + return false + } + + }) + .centerCrop() + .into(this) } }