feat: 优化

pull/226/head
kunfei 5 years ago
parent 476e1b8ad4
commit e6ba8339d1
  1. 54
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt

@ -30,35 +30,35 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack
if (item.image.isNullOrBlank() && !callBack.isGridLayout) { if (item.image.isNullOrBlank() && !callBack.isGridLayout) {
image_view.gone() image_view.gone()
} else { } else {
val imageLoader = ImageLoader.load(context, item.image) ImageLoader.load(context, item.image).apply {
if (callBack.isGridLayout) { if (callBack.isGridLayout) {
imageLoader.placeholder(R.drawable.image_rss_article) placeholder(R.drawable.image_rss_article)
} else { } else {
imageLoader.addListener(object : RequestListener<Drawable> { addListener(object : RequestListener<Drawable> {
override fun onLoadFailed( override fun onLoadFailed(
e: GlideException?, e: GlideException?,
model: Any?, model: Any?,
target: Target<Drawable>?, target: Target<Drawable>?,
isFirstResource: Boolean isFirstResource: Boolean
): Boolean { ): Boolean {
image_view.gone() image_view.gone()
return false return false
} }
override fun onResourceReady( override fun onResourceReady(
resource: Drawable?, resource: Drawable?,
model: Any?, model: Any?,
target: Target<Drawable>?, target: Target<Drawable>?,
dataSource: DataSource?, dataSource: DataSource?,
isFirstResource: Boolean isFirstResource: Boolean
): Boolean { ): Boolean {
image_view.visible() image_view.visible()
return false return false
} }
}) })
} }
imageLoader.into(image_view) }.into(image_view)
} }
if (item.read) { if (item.read) {
tv_title.textColorResource = R.color.tv_text_summary tv_title.textColorResource = R.color.tv_text_summary

Loading…
Cancel
Save