From 93f817c9c703109e27c38bf84965e8065b63e4ec Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 27 Aug 2019 23:06:28 +0800 Subject: [PATCH] up --- .../ui/changesource/ChangeSourceAdapter.kt | 19 ++++++++----------- .../app/ui/changesource/ChangeSourceDialog.kt | 3 +-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt index 45e9da565..0d7d3718b 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt @@ -11,25 +11,22 @@ import kotlinx.android.synthetic.main.item_change_source.view.* import org.jetbrains.anko.sdk27.listeners.onClick -class ChangeSourceAdapter(context: Context) : SimpleRecyclerAdapter(context, R.layout.item_change_source) { - - var callBack: CallBack? = null +class ChangeSourceAdapter(context: Context, val callBack: CallBack) : + SimpleRecyclerAdapter(context, R.layout.item_change_source) { override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList) { holder.itemView.apply { if (payloads.isEmpty()) { this.onClick { - callBack?.changeTo(item) + callBack.changeTo(item) } tv_origin.text = item.originName tv_last.text = item.latestChapterTitle - callBack?.let { - if (it.curBookUrl() == item.bookUrl) { - iv_checked.visible() - } else { - iv_checked.invisible() - } - } ?: iv_checked.invisible() + if (callBack.curBookUrl() == item.bookUrl) { + iv_checked.visible() + } else { + iv_checked.invisible() + } } else { tv_origin.text = item.originName tv_last.text = item.latestChapterTitle diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt index 4ff4b8838..cb13679fe 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt @@ -78,8 +78,7 @@ class ChangeSourceDialog : DialogFragment(), } private fun initRecyclerView() { - changeSourceAdapter = ChangeSourceAdapter(requireContext()) - changeSourceAdapter.callBack = this + changeSourceAdapter = ChangeSourceAdapter(requireContext(), this) recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayout.VERTICAL)) recycler_view.adapter = changeSourceAdapter