Search in sources :

Example 1 with Field

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;
        }
    }
}
Also used : Field(com.google.android.libraries.places.api.model.Place.Field)

Example 2 with Field

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);
}
Also used : Field(com.google.android.libraries.places.api.model.Place.Field) ArrayList(java.util.ArrayList)

Example 3 with Field

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));
}
Also used : Field(com.google.android.libraries.places.api.model.Place.Field) FetchPlaceRequest(com.google.android.libraries.places.api.net.FetchPlaceRequest) FetchPlaceResponse(com.google.android.libraries.places.api.net.FetchPlaceResponse)

Aggregations

Field (com.google.android.libraries.places.api.model.Place.Field)3 FetchPlaceRequest (com.google.android.libraries.places.api.net.FetchPlaceRequest)1 FetchPlaceResponse (com.google.android.libraries.places.api.net.FetchPlaceResponse)1 ArrayList (java.util.ArrayList)1