diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt index 7b56df2aa..7d092aa61 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.rss.article +import android.annotation.SuppressLint import android.content.Context import android.graphics.drawable.Drawable import com.bumptech.glide.load.DataSource @@ -21,15 +22,19 @@ import org.jetbrains.anko.textColorResource class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack) : SimpleRecyclerAdapter(context, layoutId) { + @SuppressLint("CheckResult") override fun convert(holder: ItemViewHolder, item: RssArticle, payloads: MutableList) { with(holder.itemView) { tv_title.text = item.title tv_pub_date.text = item.pubDate - if (item.image.isNullOrBlank()) { + if (item.image.isNullOrBlank() && !callBack.isGridLayout) { image_view.gone() } else { - ImageLoader.load(context, item.image) - .addListener(object : RequestListener { + val glide = ImageLoader.load(context, item.image) + if (callBack.isGridLayout) { + glide.placeholder(R.drawable.image_rss_article) + } else { + glide.addListener(object : RequestListener { override fun onLoadFailed( e: GlideException?, 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) { tv_title.textColorResource = R.color.tv_text_summary @@ -71,6 +77,7 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack } interface CallBack { + val isGridLayout: Boolean fun readRss(rssArticle: RssArticle) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt index 0b116a854..f2329cb84 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt @@ -43,6 +43,8 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme lateinit var adapter: RssArticlesAdapter private lateinit var loadMoreView: LoadMoreView private var rssArticlesData: LiveData>? = null + override val isGridLayout: Boolean + get() = activityViewModel.isGridLayout override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { viewModel.init(arguments) diff --git a/app/src/main/res/drawable/image_rss_article.jpg b/app/src/main/res/drawable/image_rss_article.jpg new file mode 100644 index 000000000..471b5650f Binary files /dev/null and b/app/src/main/res/drawable/image_rss_article.jpg differ diff --git a/app/src/main/res/layout/item_rss_article.xml b/app/src/main/res/layout/item_rss_article.xml index df31c7d70..311944d98 100644 --- a/app/src/main/res/layout/item_rss_article.xml +++ b/app/src/main/res/layout/item_rss_article.xml @@ -43,6 +43,7 @@ android:paddingLeft="16dp" android:visibility="gone" android:scaleType="centerCrop" + android:src="@drawable/image_rss_article" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" tools:ignore="RtlHardcoded,RtlSymmetry" />