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) {
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())

@ -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)
}
}

@ -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)
}

@ -13,7 +13,7 @@ class CoverAdapter(context: Context, val callBack: CallBack) :
override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList<Any>) {
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!!)

@ -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())
}

@ -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)

@ -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)

@ -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<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean
): Boolean {
setName(name)
return false
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
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<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean
): Boolean {
setName(name, author)
return false
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
setName(null, null)
return false
}
})
.centerCrop()
.into(this)
}
}

Loading…
Cancel
Save