diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt index 0a0168bf5..cd0756c35 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt @@ -12,7 +12,8 @@ import io.legado.app.lib.theme.ATH import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_rss_artivles.* -class RssArticlesActivity : VMBaseActivity(R.layout.activity_rss_artivles) { +class RssArticlesActivity : VMBaseActivity(R.layout.activity_rss_artivles), + RssArticlesAdapter.CallBack { override val viewModel: RssArticlesViewModel get() = getViewModel(RssArticlesViewModel::class.java) @@ -33,7 +34,7 @@ class RssArticlesActivity : VMBaseActivity(R.layout.activi private fun initView() { ATH.applyEdgeEffectColor(recycler_view) recycler_view.layoutManager = LinearLayoutManager(this) - adapter = RssArticlesAdapter(this) + adapter = RssArticlesAdapter(this, this) recycler_view.adapter = adapter refresh_progress_bar.isAutoLoading = true } @@ -45,4 +46,8 @@ class RssArticlesActivity : VMBaseActivity(R.layout.activi adapter?.setItems(it) }) } + + override fun readRss(rssArticle: RssArticle) { + + } } \ No newline at end of file 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 0e185ab22..cb209dc37 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 @@ -6,22 +6,28 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.RssArticle 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(context, R.layout.item_rss_article) { override fun convert(holder: ItemViewHolder, item: RssArticle, payloads: MutableList) { with(holder.itemView) { - title.text = item.title - pub_date.text = item.pubDate + tv_title.text = item.title + tv_pub_date.text = item.pubDate if (item.author.isNullOrBlank()) { - author.text = item.link + tv_author.text = item.link } else { - author.text = item.author + tv_author.text = item.author + } + onClick { + callBack.readRss(item) } } } - + interface CallBack { + fun readRss(rssArticle: RssArticle) + } } \ No newline at end of file diff --git a/app/src/main/res/layout/item_rss_article.xml b/app/src/main/res/layout/item_rss_article.xml index d406fc228..8f9c1d03b 100644 --- a/app/src/main/res/layout/item_rss_article.xml +++ b/app/src/main/res/layout/item_rss_article.xml @@ -14,7 +14,7 @@ android:layout_height="wrap_content">