use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class EventDetailsStepOne method setupPlacesAutocomplete.
private void setupPlacesAutocomplete() {
ApplicationInfo ai = null;
try {
ai = getContext().getPackageManager().getApplicationInfo(getContext().getPackageName(), PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
Bundle bundle = ai.metaData;
String placesApiKey = bundle.getString("com.google.android.geo.API_KEY");
Places.initialize(getActivity().getApplicationContext(), placesApiKey);
AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment) getChildFragmentManager().findFragmentById(R.id.autocomplete_fragment);
autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG, Place.Field.ADDRESS));
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
Timber.d(place.getAddress());
Event event = binding.getEvent();
event.latitude = place.getLatLng().latitude;
event.longitude = place.getLatLng().longitude;
event.locationName = place.getAddress();
event.searchableLocationName = place.getName();
}
@Override
public void onError(Status status) {
ViewUtils.showSnackbar(binding.getRoot(), status.getStatusMessage());
}
});
}
Aggregations