pull/84/head
kunfei 5 years ago
parent c8a47f7891
commit 9acd86f556
  1. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt
  4. 2
      app/src/main/java/io/legado/app/ui/changecover/CoverAdapter.kt
  5. 2
      app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt
  6. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt
  7. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt
  8. 66
      app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt

@ -147,7 +147,7 @@ class BookInfoActivity :
} }
private fun showCover(book: Book) { 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()) ImageLoader.load(this, book.getDisplayCover())
.transition(DrawableTransitionOptions.withCrossFade(1500)) .transition(DrawableTransitionOptions.withCrossFade(1500))
.thumbnail(defaultCover()) .thumbnail(defaultCover())

@ -59,7 +59,7 @@ class BookInfoEditActivity :
private fun upCover() { private fun upCover() {
viewModel.book.let { viewModel.book.let {
iv_cover.load(it?.getDisplayCover(), it?.name) iv_cover.load(it?.getDisplayCover(), it?.name, it?.author)
} }
} }

@ -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 { onClick {
callBack.showBookInfo(searchBook.name, searchBook.author) callBack.showBookInfo(searchBook.name, searchBook.author)
} }

@ -13,7 +13,7 @@ class CoverAdapter(context: Context, val callBack: CallBack) :
override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList<Any>) { override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList<Any>) {
with(holder.itemView) { with(holder.itemView) {
iv_cover.load(item.coverUrl, item.name) iv_cover.load(item.coverUrl, item.name, item.author)
tv_source.text = item.originName tv_source.text = item.originName
onClick { onClick {
callBack.changeTo(item.coverUrl!!) callBack.changeTo(item.coverUrl!!)

@ -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 { onClick {
callBack.showBookInfo(item.toBook()) callBack.showBookInfo(item.toBook())
} }

@ -20,7 +20,7 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
ATH.applyBackgroundTint(this) ATH.applyBackgroundTint(this)
tv_name.text = item.name tv_name.text = item.name
bv_author.text = item.author 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) } onClick { callBack.open(item) }
onLongClick { onLongClick {
callBack.openBookInfo(item) callBack.openBookInfo(item)

@ -22,7 +22,7 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
tv_author.text = item.author tv_author.text = item.author
tv_read.text = item.durChapterTitle tv_read.text = item.durChapterTitle
tv_last.text = item.latestChapterTitle 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) } onClick { callBack.open(item) }
onLongClick { onLongClick {
callBack.openBookInfo(item) callBack.openBookInfo(item)

@ -20,6 +20,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView {
private val textPaint = TextPaint() private val textPaint = TextPaint()
private var name: String? = null private var name: String? = null
private var author: String? = null
constructor(context: Context) : super(context) 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.name = name
this.author = author
invalidate() invalidate()
} }
@ -91,38 +93,34 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView {
minimumWidth = width minimumWidth = width
} }
fun load(path: String?, name: String?) { fun load(path: String?, name: String?, author: String?) {
if (path.isNullOrEmpty()) { ImageLoader.load(context, path)//Glide自动识别http://和file://
setName(name) .placeholder(R.drawable.image_cover_default)
} else { .error(R.drawable.image_cover_default)
ImageLoader.load(context, path)//Glide自动识别http://和file:// .listener(object : RequestListener<Drawable> {
.placeholder(R.drawable.image_cover_default) override fun onLoadFailed(
.error(R.drawable.image_cover_default) e: GlideException?,
.listener(object : RequestListener<Drawable> { model: Any?,
override fun onLoadFailed( target: Target<Drawable>?,
e: GlideException?, isFirstResource: Boolean
model: Any?, ): Boolean {
target: Target<Drawable>?, setName(name, author)
isFirstResource: Boolean return false
): Boolean { }
setName(name)
return false override fun onResourceReady(
} resource: Drawable?,
model: Any?,
override fun onResourceReady( target: Target<Drawable>?,
resource: Drawable?, dataSource: DataSource?,
model: Any?, isFirstResource: Boolean
target: Target<Drawable>?, ): Boolean {
dataSource: DataSource?, setName(null, null)
isFirstResource: Boolean return false
): Boolean { }
setName(null)
return false })
} .centerCrop()
.into(this)
})
.centerCrop()
.into(this)
}
} }
} }

Loading…
Cancel
Save