use of com.google.android.libraries.places.api.model.Place.Field in project android-places-demos by googlemaps.
the class FieldSelector method restoreState.
private void restoreState(List<Integer> selectedFields) {
for (Integer serializedField : selectedFields) {
Field field = Field.values()[serializedField];
State state = fieldStates.get(field);
if (state != null) {
state.checked = true;
}
}
}
use of com.google.android.libraries.places.api.model.Place.Field in project android-places-demos by googlemaps.
the class FieldSelector method onSaveInstanceState.
public void onSaveInstanceState(@NonNull Bundle bundle) {
List<Field> fields = getSelectedFields();
ArrayList<Integer> serializedFields = new ArrayList<>();
for (Field field : fields) {
serializedFields.add(field.ordinal());
}
bundle.putIntegerArrayList(SELECTED_PLACE_FIELDS_KEY, serializedFields);
}
use of com.google.android.libraries.places.api.model.Place.Field in project android-places-demos by googlemaps.
the class PlaceAndPhotoTestActivity method fetchPlace.
/**
* Fetches the {@link Place} specified via the UI and displays it. May also trigger {@link
* #fetchPhoto(PhotoMetadata)} if set in the UI.
*/
private void fetchPlace() {
responseView.setText(null);
photoView.setImageBitmap(null);
dismissKeyboard(findViewById(R.id.place_id_field));
final boolean isFetchPhotoChecked = isFetchPhotoChecked();
List<Field> placeFields = getPlaceFields();
String customPhotoReference = getCustomPhotoReference();
if (!validateInputs(isFetchPhotoChecked, placeFields, customPhotoReference)) {
return;
}
setLoading(true);
FetchPlaceRequest request = FetchPlaceRequest.newInstance(getPlaceId(), placeFields);
Task<FetchPlaceResponse> placeTask = placesClient.fetchPlace(request);
placeTask.addOnSuccessListener((response) -> {
responseView.setText(StringUtil.stringify(response, isDisplayRawResultsChecked()));
if (isFetchPhotoChecked) {
attemptFetchPhoto(response.getPlace());
}
});
placeTask.addOnFailureListener((exception) -> {
exception.printStackTrace();
responseView.setText(exception.getMessage());
});
placeTask.addOnCompleteListener(response -> setLoading(false));
}
Aggregations