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. 14
      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,10 +93,7 @@ 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()) {
setName(name)
} else {
ImageLoader.load(context, path)//Glide自动识别http://和file:// ImageLoader.load(context, path)//Glide自动识别http://和file://
.placeholder(R.drawable.image_cover_default) .placeholder(R.drawable.image_cover_default)
.error(R.drawable.image_cover_default) .error(R.drawable.image_cover_default)
@ -105,7 +104,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView {
target: Target<Drawable>?, target: Target<Drawable>?,
isFirstResource: Boolean isFirstResource: Boolean
): Boolean { ): Boolean {
setName(name) setName(name, author)
return false return false
} }
@ -116,7 +115,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView {
dataSource: DataSource?, dataSource: DataSource?,
isFirstResource: Boolean isFirstResource: Boolean
): Boolean { ): Boolean {
setName(null) setName(null, null)
return false return false
} }
@ -124,5 +123,4 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView {
.centerCrop() .centerCrop()
.into(this) .into(this)
} }
}
} }

Loading…
Cancel
Save