Make sure the popup menu is dismissed when the toolbar or the search icon are clicked in the MerchantsFragment.

master
Severiano Jaramillo 2019-01-30 12:11:57 -06:00
parent 1505a5642c
commit e328eb149b
1 changed files with 4 additions and 0 deletions

View File

@ -123,6 +123,8 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
(activity as AppCompatActivity).supportActionBar?.setDisplayHomeAsUpEnabled(true)
setHasOptionsMenu(true)
toolbar?.setOnClickListener { dismissPopupWindow() }
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
val mapFragment = childFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
@ -193,6 +195,8 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
mSearchView?.setOnSuggestionListener(this)
mSearchView?.setOnSearchClickListener { dismissPopupWindow() }
// Adjust SearchView width to avoid pushing other menu items out of the screen
mSearchView?.maxWidth = screenWidth * 7 / 10
}