com.google.android.gms.location.places.PlacePhotoMetadata Java Examples
The following examples show how to use
com.google.android.gms.location.places.PlacePhotoMetadata.
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: PhotoTask.java From Place-Search-Service with MIT License | 5 votes |
@Override protected List<AttributedPhoto> doInBackground(String... params) { if (params.length != 1) { return null; } final String placeId = params[0]; AttributedPhoto attributedPhoto = null; PlacePhotoMetadataResult result = Places.GeoDataApi .getPlacePhotos(mGoogleApiClient, placeId).await(); List<AttributedPhoto> list = new ArrayList<>(); if (result.getStatus().isSuccess()) { PlacePhotoMetadataBuffer photoMetadataBuffer = result.getPhotoMetadata(); if (photoMetadataBuffer.getCount() > 0 && !isCancelled()) { for (int index = 0;index<photoMetadataBuffer.getCount();index++) { PlacePhotoMetadata photo = photoMetadataBuffer.get(index); CharSequence attribution = photo.getAttributions(); Bitmap image = photo.getScaledPhoto(mGoogleApiClient, mWidth, mHeight).await() .getBitmap(); attributedPhoto = new AttributedPhoto(attribution, image); list.add(attributedPhoto); } } photoMetadataBuffer.release(); } return list; }
Example #2
Source File: PhotoTask.java From protrip with MIT License | 5 votes |
/** * Loads the first photo for a place id from the Geo Data API. * The place id must be the first (and only) parameter. */ @Override protected AttributedPhoto doInBackground(String... params) { if (params.length != 1) { return null; } final String placeId = params[0]; AttributedPhoto attributedPhoto = null; PlacePhotoMetadataResult result = Places.GeoDataApi .getPlacePhotos(mGoogleApiClient, placeId).await(); if (result.getStatus().isSuccess()) { PlacePhotoMetadataBuffer photoMetadataBuffer = result.getPhotoMetadata(); if (photoMetadataBuffer.getCount() > 0 && !isCancelled()) { // Get the first bitmap and its attributions. PlacePhotoMetadata photo = photoMetadataBuffer.get(0); CharSequence attribution = photo.getAttributions(); // Load a scaled bitmap for this photo. Bitmap image = photo.getScaledPhoto(mGoogleApiClient, mWidth, mHeight).await() .getBitmap(); attributedPhoto = new AttributedPhoto(attribution, image); } // Release the PlacePhotoMetadataBuffer. photoMetadataBuffer.release(); } return attributedPhoto; }