pull/1434/head
gedoor 3 years ago
parent 44a5ab4b44
commit cd79e497da
  1. 23
      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() {

Loading…
Cancel
Save