Commit f8bea663 authored by Viktor De Pasquale's avatar Viktor De Pasquale Committed by John Wu

Fixed menu inflating unnecessarily on every click

parent dd912901
......@@ -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)
tag = menu.apply {
this.menu.clear()
menuInflater.inflate(popupMenu, this.menu)
setOnMenuItemClickListener {
listener.onMenuItemClick(it.itemId)
true
}
show()
}
setOnClickListener {
(tag as PopupMenu).show()
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment