pull/32/head
kunfei 5 years ago
parent 277ea66b99
commit 93f817c9c7
  1. 19
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt
  2. 3
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt

@ -11,25 +11,22 @@ import kotlinx.android.synthetic.main.item_change_source.view.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
class ChangeSourceAdapter(context: Context) : SimpleRecyclerAdapter<SearchBook>(context, R.layout.item_change_source) { class ChangeSourceAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<SearchBook>(context, R.layout.item_change_source) {
var callBack: CallBack? = null
override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList<Any>) { override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList<Any>) {
holder.itemView.apply { holder.itemView.apply {
if (payloads.isEmpty()) { if (payloads.isEmpty()) {
this.onClick { this.onClick {
callBack?.changeTo(item) callBack.changeTo(item)
} }
tv_origin.text = item.originName tv_origin.text = item.originName
tv_last.text = item.latestChapterTitle tv_last.text = item.latestChapterTitle
callBack?.let { if (callBack.curBookUrl() == item.bookUrl) {
if (it.curBookUrl() == item.bookUrl) { iv_checked.visible()
iv_checked.visible() } else {
} else { iv_checked.invisible()
iv_checked.invisible() }
}
} ?: iv_checked.invisible()
} else { } else {
tv_origin.text = item.originName tv_origin.text = item.originName
tv_last.text = item.latestChapterTitle tv_last.text = item.latestChapterTitle

@ -78,8 +78,7 @@ class ChangeSourceDialog : DialogFragment(),
} }
private fun initRecyclerView() { private fun initRecyclerView() {
changeSourceAdapter = ChangeSourceAdapter(requireContext()) changeSourceAdapter = ChangeSourceAdapter(requireContext(), this)
changeSourceAdapter.callBack = this
recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.layoutManager = LinearLayoutManager(context)
recycler_view.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayout.VERTICAL)) recycler_view.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayout.VERTICAL))
recycler_view.adapter = changeSourceAdapter recycler_view.adapter = changeSourceAdapter

Loading…
Cancel
Save