feat: 优化

pull/219/head
kunfei 5 years ago
parent 5f5cb39793
commit 5c1ab9d017
  1. 15
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt
  2. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt
  3. BIN
      app/src/main/res/drawable/image_rss_article.jpg
  4. 1
      app/src/main/res/layout/item_rss_article.xml

@ -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<RssArticle>(context, layoutId) {
@SuppressLint("CheckResult")
override fun convert(holder: ItemViewHolder, item: RssArticle, payloads: MutableList<Any>) {
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<Drawable> {
val glide = ImageLoader.load(context, item.image)
if (callBack.isGridLayout) {
glide.placeholder(R.drawable.image_rss_article)
} else {
glide.addListener(object : RequestListener<Drawable> {
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)
}
}

@ -43,6 +43,8 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
lateinit var adapter: RssArticlesAdapter
private lateinit var loadMoreView: LoadMoreView
private var rssArticlesData: LiveData<List<RssArticle>>? = null
override val isGridLayout: Boolean
get() = activityViewModel.isGridLayout
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
viewModel.init(arguments)

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -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" />

Loading…
Cancel
Save