|
|
@ -1,5 +1,6 @@ |
|
|
|
package io.legado.app.ui.rss.article |
|
|
|
package io.legado.app.ui.rss.article |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import com.bumptech.glide.load.DataSource |
|
|
|
import com.bumptech.glide.load.DataSource |
|
|
@ -21,15 +22,19 @@ import org.jetbrains.anko.textColorResource |
|
|
|
class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack) : |
|
|
|
class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack) : |
|
|
|
SimpleRecyclerAdapter<RssArticle>(context, layoutId) { |
|
|
|
SimpleRecyclerAdapter<RssArticle>(context, layoutId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("CheckResult") |
|
|
|
override fun convert(holder: ItemViewHolder, item: RssArticle, payloads: MutableList<Any>) { |
|
|
|
override fun convert(holder: ItemViewHolder, item: RssArticle, payloads: MutableList<Any>) { |
|
|
|
with(holder.itemView) { |
|
|
|
with(holder.itemView) { |
|
|
|
tv_title.text = item.title |
|
|
|
tv_title.text = item.title |
|
|
|
tv_pub_date.text = item.pubDate |
|
|
|
tv_pub_date.text = item.pubDate |
|
|
|
if (item.image.isNullOrBlank()) { |
|
|
|
if (item.image.isNullOrBlank() && !callBack.isGridLayout) { |
|
|
|
image_view.gone() |
|
|
|
image_view.gone() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ImageLoader.load(context, item.image) |
|
|
|
val glide = ImageLoader.load(context, item.image) |
|
|
|
.addListener(object : RequestListener<Drawable> { |
|
|
|
if (callBack.isGridLayout) { |
|
|
|
|
|
|
|
glide.placeholder(R.drawable.image_rss_article) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
glide.addListener(object : RequestListener<Drawable> { |
|
|
|
override fun onLoadFailed( |
|
|
|
override fun onLoadFailed( |
|
|
|
e: GlideException?, |
|
|
|
e: GlideException?, |
|
|
|
model: Any?, |
|
|
|
model: Any?, |
|
|
@ -52,7 +57,8 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.into(image_view) |
|
|
|
} |
|
|
|
|
|
|
|
glide.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 |
|
|
@ -71,6 +77,7 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CallBack { |
|
|
|
interface CallBack { |
|
|
|
|
|
|
|
val isGridLayout: Boolean |
|
|
|
fun readRss(rssArticle: RssArticle) |
|
|
|
fun readRss(rssArticle: RssArticle) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |