pull/94/head
kunfei 5 years ago
parent dbb2c19125
commit 89c8a72ce1
  1. 11
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  2. 20
      app/src/main/res/menu/explore_item.xml
  3. 3
      app/src/main/res/values/ids.xml

@ -2,8 +2,8 @@ package io.legado.app.ui.main.explore
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu
import android.widget.PopupMenu import android.widget.PopupMenu
import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
@ -40,9 +40,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
} }
ll_title.onLongClick { ll_title.onLongClick {
val popupMenu = PopupMenu(context, ll_title) val popupMenu = PopupMenu(context, ll_title)
popupMenu.menu.add(Menu.NONE, R.id.menu_edit, Menu.NONE, R.string.edit) popupMenu.inflate(R.menu.explore_item)
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.setOnMenuItemClickListener { popupMenu.setOnMenuItemClickListener {
when (it.itemId) { when (it.itemId) {
R.id.menu_edit -> callBack.editSource(item.bookSourceUrl) 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) ACache.get(context, "explore").remove(item.bookSourceUrl)
notifyItemChanged(holder.layoutPosition) notifyItemChanged(holder.layoutPosition)
} }
R.id.menu_del -> {
Coroutine.async(scope) {
App.db.bookSourceDao().delete(item)
}
}
} }
true true
} }

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_edit"
android:title="@string/edit" />
<item
android:id="@+id/menu_top"
android:title="@string/to_top" />
<item
android:id="@+id/menu_refresh"
android:title="@string/refresh" />
<item
android:id="@+id/menu_del"
android:title="@string/delete" />
</menu>

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<item name="menu_edit" type="id" />
<item name="menu_del" type="id" />
<item name="menu_top" type="id" />
<item name="tag1" type="id" /> <item name="tag1" type="id" />
<item name="tag2" type="id" /> <item name="tag2" type="id" />

Loading…
Cancel
Save