From 89c8a72ce1cc23f19cfea754471f130df09b808a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 8 Feb 2020 17:04:51 +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 --- .../app/ui/main/explore/ExploreAdapter.kt | 11 ++++++---- app/src/main/res/menu/explore_item.xml | 20 +++++++++++++++++++ app/src/main/res/values/ids.xml | 3 --- 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/menu/explore_item.xml diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt index 144fa4e19..e3fb6f190 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt @@ -2,8 +2,8 @@ package io.legado.app.ui.main.explore import android.content.Context import android.view.LayoutInflater -import android.view.Menu import android.widget.PopupMenu +import io.legado.app.App import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter @@ -40,9 +40,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca } ll_title.onLongClick { val popupMenu = PopupMenu(context, ll_title) - popupMenu.menu.add(Menu.NONE, R.id.menu_edit, Menu.NONE, R.string.edit) - popupMenu.menu.add(Menu.NONE, R.id.menu_top, Menu.NONE, R.string.to_top) - popupMenu.menu.add(Menu.NONE, R.id.menu_refresh, Menu.NONE, R.string.refresh) + popupMenu.inflate(R.menu.explore_item) popupMenu.setOnMenuItemClickListener { when (it.itemId) { R.id.menu_edit -> callBack.editSource(item.bookSourceUrl) @@ -51,6 +49,11 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca ACache.get(context, "explore").remove(item.bookSourceUrl) notifyItemChanged(holder.layoutPosition) } + R.id.menu_del -> { + Coroutine.async(scope) { + App.db.bookSourceDao().delete(item) + } + } } true } diff --git a/app/src/main/res/menu/explore_item.xml b/app/src/main/res/menu/explore_item.xml new file mode 100644 index 000000000..8cc2fe0c3 --- /dev/null +++ b/app/src/main/res/menu/explore_item.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 016946f36..cc2d9c170 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -1,8 +1,5 @@ - - -