Show merchants and tellers suggestions in MerchantsFragment's SearchView if they are enabled in the popup window.

This commit is contained in:
Severiano Jaramillo 2019-01-29 10:44:08 -06:00
parent 732d48796b
commit 5fc5db88c2

View file

@ -127,7 +127,7 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
} }
private fun setupPopupWindow() { private fun setupPopupWindow() {
val popupView = layoutInflater?.inflate(R.layout.popup_menu_merchants, null) val popupView = layoutInflater?.inflate(R.layout.popup_menu_merchants, null, false)
val switchMerchants = popupView?.findViewById<SwitchCompat>(R.id.switchMerchants) val switchMerchants = popupView?.findViewById<SwitchCompat>(R.id.switchMerchants)
switchMerchants?.isChecked = showMerchantsMarkers switchMerchants?.isChecked = showMerchantsMarkers
@ -199,6 +199,9 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
mDisposables.add(Observable.zip(merchantsObs, tellerObs, mDisposables.add(Observable.zip(merchantsObs, tellerObs,
BiFunction<List<Merchant>, List<Teller>, List<MapObject>> { t1, t2 -> BiFunction<List<Merchant>, List<Teller>, List<MapObject>> { t1, t2 ->
val mapObjects = ArrayList<MapObject>() val mapObjects = ArrayList<MapObject>()
// Show merchant suggestions only if merchants are enabled
if (showMerchantsMarkers) {
for (merchant in t1) { for (merchant in t1) {
val mapObject = MapObject( val mapObject = MapObject(
merchant._id, merchant._id,
@ -210,7 +213,10 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
) )
mapObjects.add(mapObject) mapObjects.add(mapObject)
} }
}
// Show teller suggestions only if tellers are enabled
if (showTellerMarkers) {
for (teller in t2) { for (teller in t2) {
val mapObject = MapObject( val mapObject = MapObject(
teller._id, teller._id,
@ -222,6 +228,7 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
) )
mapObjects.add(mapObject) mapObjects.add(mapObject)
} }
}
mapObjects mapObjects
} }