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

项目:GitHub    文件:ReactiveLocationProvider.java   
/**
 * Returns observable that fetches a placePhotoMetadata from the Places API using the place placePhotoMetadata metadata.
 * Use after fetching the place placePhotoMetadata metadata with {@link ReactiveLocationProvider#getPhotoMetadataById(String)}
 *
 * @param placePhotoMetadata the place photo meta data
 * @return observable that emits the photo result and completes
 */
public Observable<PlacePhotoResult> getPhotoForMetadata(final PlacePhotoMetadata placePhotoMetadata) {
    return getGoogleApiClientObservable(Places.PLACE_DETECTION_API, Places.GEO_DATA_API)
            .flatMap(new Func1<GoogleApiClient, Observable<PlacePhotoResult>>() {
                @Override
                public Observable<PlacePhotoResult> call(GoogleApiClient api) {
                    return fromPendingResult(placePhotoMetadata.getPhoto(api));
                }
            });
}
项目: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;
}
项目:RxTask    文件:RxGeoDataClient.java   
@NonNull
public Single<PlacePhotoResponse> getPhoto(PlacePhotoMetadata photoMetadata) {
    return SingleTask.create(() -> client.getPhoto(photoMetadata));
}
项目:RxTask    文件:RxGeoDataClient.java   
@NonNull
public Single<PlacePhotoResponse> getScaledPhoto(PlacePhotoMetadata photoMetadata, int width,
                                                 int height) {
    return SingleTask.create(() -> client.getScaledPhoto(photoMetadata, width, height));
}