Could have implemented this check (if menu is showing) inside the show() method of BrowserMenu but this would mean the client (us) would go to the process of building a new menu and then trying to have it displayed only for this to be ignored by BrowserMenu in a somewhat opaque way. Having this check done as soon as possible offers us full control and avoids the unnecessary steps for building an already shown menu.master
parent
17d183ea0b
commit
8f0325c05b
|
@ -245,11 +245,19 @@ class HomeFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
view.menuButton.setOnClickListener {
|
||||
homeMenu?.menuBuilder?.build(requireContext())?.show(
|
||||
anchor = it,
|
||||
orientation = BrowserMenu.Orientation.DOWN
|
||||
)
|
||||
with(view.menuButton) {
|
||||
var menu: PopupWindow? = null
|
||||
setOnClickListener {
|
||||
if (menu == null) {
|
||||
menu = homeMenu?.menuBuilder?.build(requireContext())?.show(
|
||||
anchor = it,
|
||||
orientation = BrowserMenu.Orientation.DOWN,
|
||||
onDismiss = { menu = null }
|
||||
)
|
||||
} else {
|
||||
menu?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
view.toolbar.compoundDrawablePadding =
|
||||
view.resources.getDimensionPixelSize(R.dimen.search_bar_search_engine_icon_padding)
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.mozilla.fenix.home.sessioncontrol.viewholders
|
|||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.PopupWindow
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.reactivex.Observer
|
||||
|
@ -55,10 +56,19 @@ class TabHeaderViewHolder(
|
|||
}
|
||||
|
||||
tabs_overflow_button.run {
|
||||
var menu: PopupWindow? = null
|
||||
setOnClickListener {
|
||||
tabsMenu.menuBuilder
|
||||
.build(view.context)
|
||||
.show(anchor = it, orientation = BrowserMenu.Orientation.DOWN)
|
||||
if (menu == null) {
|
||||
menu = tabsMenu.menuBuilder
|
||||
.build(view.context)
|
||||
.show(
|
||||
anchor = it,
|
||||
orientation = BrowserMenu.Orientation.DOWN,
|
||||
onDismiss = { menu = null }
|
||||
)
|
||||
} else {
|
||||
menu?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue