pull/35/head^2
kunfei 5 years ago
parent fa01c3781c
commit e8f438e84e
  1. 9
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt
  2. 18
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt
  3. 6
      app/src/main/res/layout/item_rss_article.xml

@ -12,7 +12,8 @@ import io.legado.app.lib.theme.ATH
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_rss_artivles.* import kotlinx.android.synthetic.main.activity_rss_artivles.*
class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activity_rss_artivles) { class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activity_rss_artivles),
RssArticlesAdapter.CallBack {
override val viewModel: RssArticlesViewModel override val viewModel: RssArticlesViewModel
get() = getViewModel(RssArticlesViewModel::class.java) get() = getViewModel(RssArticlesViewModel::class.java)
@ -33,7 +34,7 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
private fun initView() { private fun initView() {
ATH.applyEdgeEffectColor(recycler_view) ATH.applyEdgeEffectColor(recycler_view)
recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.layoutManager = LinearLayoutManager(this)
adapter = RssArticlesAdapter(this) adapter = RssArticlesAdapter(this, this)
recycler_view.adapter = adapter recycler_view.adapter = adapter
refresh_progress_bar.isAutoLoading = true refresh_progress_bar.isAutoLoading = true
} }
@ -45,4 +46,8 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
adapter?.setItems(it) adapter?.setItems(it)
}) })
} }
override fun readRss(rssArticle: RssArticle) {
}
} }

@ -6,22 +6,28 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.RssArticle import io.legado.app.data.entities.RssArticle
import kotlinx.android.synthetic.main.item_rss_article.view.* import kotlinx.android.synthetic.main.item_rss_article.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
class RssArticlesAdapter(context: Context) : class RssArticlesAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<RssArticle>(context, R.layout.item_rss_article) { SimpleRecyclerAdapter<RssArticle>(context, R.layout.item_rss_article) {
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) {
title.text = item.title tv_title.text = item.title
pub_date.text = item.pubDate tv_pub_date.text = item.pubDate
if (item.author.isNullOrBlank()) { if (item.author.isNullOrBlank()) {
author.text = item.link tv_author.text = item.link
} else { } else {
author.text = item.author tv_author.text = item.author
}
onClick {
callBack.readRss(item)
} }
} }
} }
interface CallBack {
fun readRss(rssArticle: RssArticle)
}
} }

@ -14,7 +14,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/title" android:id="@+id/tv_title"
android:textSize="18sp" android:textSize="18sp"
android:text="Title" android:text="Title"
android:layout_gravity="center" android:layout_gravity="center"
@ -23,7 +23,7 @@
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView <TextView
android:id="@+id/pub_date" android:id="@+id/tv_pub_date"
android:textSize="12sp" android:textSize="12sp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
@ -34,7 +34,7 @@
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView <TextView
android:id="@+id/author" android:id="@+id/tv_author"
android:textSize="16sp" android:textSize="16sp"
android:text="author" android:text="author"
android:layout_gravity="center" android:layout_gravity="center"

Loading…
Cancel
Save