Java 类com.google.android.gms.location.places.PlacePhotoMetadataResult 实例源码

项目:GitHub    文件:ReactiveLocationProvider.java   
/**
 * Returns observable that fetches photo metadata from the Places API using the place ID.
 *
 * @param placeId id for place
 * @return observable that emits metadata buffer and completes
 */
public Observable<PlacePhotoMetadataResult> getPhotoMetadataById(final String placeId) {
    return getGoogleApiClientObservable(Places.PLACE_DETECTION_API, Places.GEO_DATA_API)
            .flatMap(new Func1<GoogleApiClient, Observable<PlacePhotoMetadataResult>>() {
                @Override
                public Observable<PlacePhotoMetadataResult> call(GoogleApiClient api) {
                    return fromPendingResult(Places.GeoDataApi.getPlacePhotos(api, placeId));
                }
            });
}
项目:protrip    文件:PhotoTask.java   
/**
 * 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;
}