|
|
@ -2,6 +2,7 @@ package io.legado.app.ui.replacerule |
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
|
|
|
|
import android.view.View |
|
|
|
import android.widget.PopupMenu |
|
|
|
import android.widget.PopupMenu |
|
|
|
import androidx.core.os.bundleOf |
|
|
|
import androidx.core.os.bundleOf |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
@ -81,16 +82,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : |
|
|
|
callBack.upCountView() |
|
|
|
callBack.upCountView() |
|
|
|
} |
|
|
|
} |
|
|
|
iv_menu_more.onClick { |
|
|
|
iv_menu_more.onClick { |
|
|
|
val popupMenu = PopupMenu(context, it) |
|
|
|
showMenu(iv_menu_more, holder.layoutPosition) |
|
|
|
popupMenu.inflate(R.menu.replace_rule_item) |
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener { menuItem -> |
|
|
|
|
|
|
|
when (menuItem.itemId) { |
|
|
|
|
|
|
|
R.id.menu_top -> callBack.toTop(item) |
|
|
|
|
|
|
|
R.id.menu_del -> callBack.delete(item) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
popupMenu.show() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
bundle.keySet().map { |
|
|
|
bundle.keySet().map { |
|
|
@ -110,6 +102,20 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun showMenu(view: View, position: Int) { |
|
|
|
|
|
|
|
val item = getItem(position) ?: return |
|
|
|
|
|
|
|
val popupMenu = PopupMenu(context, view) |
|
|
|
|
|
|
|
popupMenu.inflate(R.menu.replace_rule_item) |
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener { menuItem -> |
|
|
|
|
|
|
|
when (menuItem.itemId) { |
|
|
|
|
|
|
|
R.id.menu_top -> callBack.toTop(item) |
|
|
|
|
|
|
|
R.id.menu_del -> callBack.delete(item) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
popupMenu.show() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { |
|
|
|
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { |
|
|
|
val srcItem = getItem(srcPosition) |
|
|
|
val srcItem = getItem(srcPosition) |
|
|
|
val targetItem = getItem(targetPosition) |
|
|
|
val targetItem = getItem(targetPosition) |
|
|
|