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 {
|
with(view.menuButton) {
|
||||||
homeMenu?.menuBuilder?.build(requireContext())?.show(
|
var menu: PopupWindow? = null
|
||||||
anchor = it,
|
setOnClickListener {
|
||||||
orientation = BrowserMenu.Orientation.DOWN
|
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.toolbar.compoundDrawablePadding =
|
||||||
view.resources.getDimensionPixelSize(R.dimen.search_bar_search_engine_icon_padding)
|
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.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.PopupWindow
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import io.reactivex.Observer
|
import io.reactivex.Observer
|
||||||
|
@ -55,10 +56,19 @@ class TabHeaderViewHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
tabs_overflow_button.run {
|
tabs_overflow_button.run {
|
||||||
|
var menu: PopupWindow? = null
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
tabsMenu.menuBuilder
|
if (menu == null) {
|
||||||
.build(view.context)
|
menu = tabsMenu.menuBuilder
|
||||||
.show(anchor = it, orientation = BrowserMenu.Orientation.DOWN)
|
.build(view.context)
|
||||||
|
.show(
|
||||||
|
anchor = it,
|
||||||
|
orientation = BrowserMenu.Orientation.DOWN,
|
||||||
|
onDismiss = { menu = null }
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
menu?.dismiss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue