diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt b/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt index e0eb1f21a..08ff13827 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt @@ -470,18 +470,19 @@ interface OnPopupMenuItemClickListener { @BindingAdapter("popupMenu", "popupMenuOnClickListener", requireAll = false) fun View.setPopupMenu(popupMenu: Int, listener: OnPopupMenuItemClickListener) { - tag = tag as? PopupMenu ?: let { + val menu = tag as? PopupMenu ?: let { val themeWrapper = ContextThemeWrapper(context, R.style.Foundation_PopupMenu) PopupMenu(themeWrapper, this) } - setOnClickListener { - (tag as PopupMenu).apply { - menuInflater.inflate(popupMenu, menu) - setOnMenuItemClickListener { - listener.onMenuItemClick(it.itemId) - true - } - show() + tag = menu.apply { + this.menu.clear() + menuInflater.inflate(popupMenu, this.menu) + setOnMenuItemClickListener { + listener.onMenuItemClick(it.itemId) + true } } + setOnClickListener { + (tag as PopupMenu).show() + } } \ No newline at end of file