pull/35/head^2
kunfei 5 years ago
parent dee7495f8f
commit b37141cbf9
  1. 13
      app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt
  2. 3
      app/src/main/res/layout/item_rss.xml

@ -5,15 +5,24 @@ import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.RssSource
import io.legado.app.help.ImageLoader
import kotlinx.android.synthetic.main.item_rss.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
class RssAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<RssSource>(context, R.layout.item_rss) {
override fun convert(holder: ItemViewHolder, item: RssSource, payloads: MutableList<Any>) {
with(holder.itemView) {
tv_name.text = item.sourceName
ImageLoader.load(context, item.sourceIcon)
.centerCrop()
.setAsBitmap(iv_icon)
onClick { callBack.openRss(item) }
}
}
interface CallBack {
fun openRss()
fun openRss(rssSource: RssSource)
}
}

@ -9,6 +9,8 @@
android:id="@+id/iv_icon"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/ic_image"
android:scaleType="centerCrop"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
@ -17,6 +19,7 @@
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iv_icon" />

Loading…
Cancel
Save