From ecc4f2f2df60207d4c6d603f60d067127c6ebbdd Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 5 Dec 2020 16:22:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=BA=90=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/subscription/SourceSubAdapter.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt index e08727b4e..c5b85ebee 100644 --- a/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt @@ -1,7 +1,10 @@ package io.legado.app.ui.rss.subscription import android.content.Context +import android.view.View import android.view.ViewGroup +import android.widget.PopupMenu +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.SourceSub @@ -31,8 +34,21 @@ class SourceSubAdapter(context: Context, val callBack: Callback) : callBack.editSubscription(getItem(holder.layoutPosition)!!) } binding.ivMenuMore.onClick { + showMenu(binding.ivMenuMore, 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_del -> callBack.delSubscription(source) + } + true } + popupMenu.show() } override fun getViewBinding(parent: ViewGroup): ItemSourceSubBinding {