Java Code Examples for com.google.android.gms.location.places.PlaceBuffer#get()

The following examples show how to use com.google.android.gms.location.places.PlaceBuffer#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoCompleteLocation.java    From AutocompleteLocation with Apache License 2.0 5 votes vote down vote up
@Override public void onResult(@NonNull PlaceBuffer places) {
  if (!places.getStatus().isSuccess()) {
    places.release();
    return;
  }
  final Place place = places.get(0);
  if (mAutoCompleteLocationListener != null) {
    mAutoCompleteLocationListener.onItemSelected(place);
  }
  places.release();
}
 
Example 2
Source File: SearchPlaceOnMapActivity.java    From Airbnb-Android-Google-Map-View with MIT License 5 votes vote down vote up
@Override
public void onResult(PlaceBuffer places) {
    if (!places.getStatus().isSuccess()) {
        places.release();
        return;
    }
    // Get the Place object from the buffer.
    final Place place = places.get(0);
    hideKeyboard();
    mLatitude=String.valueOf(place.getLatLng().latitude);
    mLongitude=String.valueOf(place.getLatLng().longitude);
    LatLng newLatLngTemp = new LatLng(place.getLatLng().latitude, place.getLatLng().longitude);
    // LatLng centerLatLng=new LatLng(mMap.getCameraPosition().target.latitude,mMap.getCameraPosition().target.longitude);
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(newLatLngTemp, 15f));
}
 
Example 3
Source File: MainActivity.java    From ExamplesAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onResult(PlaceBuffer places) {
    if (!places.getStatus().isSuccess()) {
        // Request did not complete successfully
        Log.e(TAG, "Place query did not complete. Error: " + places.getStatus().toString());
        places.release();
        return;
    }
    // Get the Place object from the buffer.
    final Place place = places.get(0);

    // Format details of the place for display and show it in a TextView.
    mPlaceDetailsText.setText(formatPlaceDetails(getResources(), place.getName(),
            place.getId(), place.getAddress(), place.getPhoneNumber(),
            place.getWebsiteUri()));

    // Display the third party attributions if set.
    final CharSequence thirdPartyAttribution = places.getAttributions();
    if (thirdPartyAttribution == null) {
        mPlaceDetailsAttribution.setVisibility(View.GONE);
    } else {
        mPlaceDetailsAttribution.setVisibility(View.VISIBLE);
        mPlaceDetailsAttribution.setText(Html.fromHtml(thirdPartyAttribution.toString()));
    }

    Log.i(TAG, "Place details received: " + place.getName());

    places.release();
}