@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final Country country = getArguments().getParcelable(CountryPickerDialog.COUNTRY); final Region region = getArguments().getParcelable(RegionPickerDialog.REGION); if (country != null && region != null) { builder.setTitle(country.getName() + ", " + region.getName()); } citiesView.setOnLocationClickedListener( new LocationView.OnLocationClickedListener<City>() { public void onLocationClicked(City city) { if (listener != null) { listener.onCitySet(city); return; } userLocation = region.getName() + "," + country.getName(); Bundle bundle = new Bundle(); bundle.putParcelable(LOCATION, city); dismiss(); dimissfragment(); } }); builder.setView(citiesView); return builder.create(); }
private void initializeCitiesView() { Region region = getArguments().getParcelable(RegionPickerDialog.REGION); if (region != null) { citiesView = new LocationView<>(getActivity()); cities = new FirebaseCities(region.getId()); cities.getAll( new DataCallback<List<City>>() { @Override public void onSuccess(List<City> data) { citiesView.setLocations(data); } @Override public void onError(String errorMessage) {} }); } }