Search in sources :

Example 1 with PlaceBuffer

use of com.google.android.gms.location.places.PlaceBuffer in project Android-ReactiveLocation by mcharmas.

the class PlacesResultActivity method onLocationPermissionGranted.

@Override
protected void onLocationPermissionGranted() {
    compositeSubscription = new CompositeSubscription();
    compositeSubscription.add(reactiveLocationProvider.getPlaceById(placeId).subscribe(new Action1<PlaceBuffer>() {

        @Override
        public void call(PlaceBuffer buffer) {
            Place place = buffer.get(0);
            if (place != null) {
                placeNameView.setText(place.getName());
                placeLocationView.setText(place.getLatLng().latitude + ", " + place.getLatLng().longitude);
                placeAddressView.setText(place.getAddress());
            }
            buffer.release();
        }
    }));
}
Also used : Action1(rx.functions.Action1) CompositeSubscription(rx.subscriptions.CompositeSubscription) PlaceBuffer(com.google.android.gms.location.places.PlaceBuffer) Place(com.google.android.gms.location.places.Place)

Example 2 with PlaceBuffer

use of com.google.android.gms.location.places.PlaceBuffer in project Android-ReactiveLocation by mcharmas.

the class PlacesResultActivity method onLocationPermissionGranted.

@Override
protected void onLocationPermissionGranted() {
    compositeSubscription = new CompositeDisposable();
    compositeSubscription.add(reactiveLocationProvider.getPlaceById(placeId).subscribe(new Consumer<PlaceBuffer>() {

        @Override
        public void accept(PlaceBuffer buffer) {
            Place place = buffer.get(0);
            if (place != null) {
                placeNameView.setText(place.getName());
                placeLocationView.setText(place.getLatLng().latitude + ", " + place.getLatLng().longitude);
                placeAddressView.setText(place.getAddress());
            }
            buffer.release();
        }
    }));
}
Also used : Consumer(io.reactivex.functions.Consumer) PlaceBuffer(com.google.android.gms.location.places.PlaceBuffer) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Place(com.google.android.gms.location.places.Place)

Aggregations

Place (com.google.android.gms.location.places.Place)2 PlaceBuffer (com.google.android.gms.location.places.PlaceBuffer)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Consumer (io.reactivex.functions.Consumer)1 Action1 (rx.functions.Action1)1 CompositeSubscription (rx.subscriptions.CompositeSubscription)1