From cd79e497da3605da4766e51156e18fef48ed21b1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 20 Nov 2021 10:58:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/local/rule/TxtTocRuleAdapter.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleAdapter.kt b/app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleAdapter.kt index 1b8a3f489..eb555453f 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleAdapter.kt @@ -1,9 +1,12 @@ package io.legado.app.ui.book.local.rule import android.content.Context +import android.view.View import android.view.ViewGroup +import android.widget.PopupMenu import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView +import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.RecyclerAdapter import io.legado.app.data.entities.TxtTocRule @@ -63,8 +66,28 @@ class TxtTocRuleAdapter(context: Context, private val callBack: CallBack) : } } binding.ivEdit.setOnClickListener { + getItem(holder.layoutPosition)?.let { + callBack.edit(it) + } + } + binding.ivMenuMore.setOnClickListener { + showMenu(it, holder.layoutPosition) + } + } + private fun showMenu(view: View, position: Int) { + val source = getItem(position) ?: return + val popupMenu = PopupMenu(context, view) + popupMenu.inflate(R.menu.rss_source_item) + popupMenu.setOnMenuItemClickListener { menuItem -> + when (menuItem.itemId) { + R.id.menu_top -> callBack.toTop(source) + R.id.menu_bottom -> callBack.toBottom(source) + R.id.menu_del -> callBack.del(source) + } + true } + popupMenu.show() } fun selectAll() {