本文整理汇总了Java中com.google.android.gms.location.places.PlaceBuffer类的典型用法代码示例。如果您正苦于以下问题:Java PlaceBuffer类的具体用法?Java PlaceBuffer怎么用?Java PlaceBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlaceBuffer类属于com.google.android.gms.location.places包,在下文中一共展示了PlaceBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLocationPermissionGranted
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@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();
}
}));
}
示例2: updateGeofencesList
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
/**
* Updates the local {@link ArrayList} of geofences from the data in the passed list
*Uses the place id defined by the API as the geofence object id.
*
* @param places the placeBuffer result of the getPlaceByid call.
*/
public void updateGeofencesList(PlaceBuffer places){
mGeofenceList = new ArrayList<>();
if (places==null || places.getCount()==0) return;
for (Place place: places){
String placeUid = place.getId();
double latitude = place.getLatLng().latitude;
double longitude = place.getLatLng().longitude;
//Build a geofence object
Geofence geofence = new Geofence.Builder()
.setRequestId(placeUid)
.setExpirationDuration(GEOFENCE_TIMEOUT)
.setCircularRegion(latitude,longitude,GEOFENCE_RADIUS)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
.build();
mGeofenceList.add(geofence);
}
}
示例3: refreshPlacesData
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
public void refreshPlacesData(){
Uri uri = PlacesContract.PlaceEntry.CONTENT_URI;
Cursor dataCursor = getContentResolver().query(uri,
null,
null,
null,null,null);
if (dataCursor==null||dataCursor.getCount()==0) return;
List<String> placeIds = new ArrayList<String>();
while (dataCursor.moveToNext()){
placeIds.add(dataCursor.getString(dataCursor.getColumnIndex(PlacesContract.PlaceEntry.COLUMN_PLACE_ID)));
}
PendingResult<PlaceBuffer> placeBufferPendingResult = Places.GeoDataApi.getPlaceById(mClient,
placeIds.toArray(new String[placeIds.size()]));
placeBufferPendingResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
mAdapter.swapPlaces(places);
mGeofencing.updateGeofencesList(places);
if (mIsEnabled) mGeofencing.registerAllGeofences();
}
});
}
示例4: onResult
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onResult(PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
places.release();
return;
}
try {
final Place place = places.get(0);
if (Preferences.getInstance(SearchActivity.this).isLogged()) {
searchPresenter.getNearStations(place.getLatLng());
places.release();
} else {
Intent returnIntent = new Intent();
returnIntent.putExtra(MapFragment.LATITUDE_SEARCH, place.getLatLng().latitude);
returnIntent.putExtra(MapFragment.LONGITUDE_SEARCH, place.getLatLng().longitude);
places.release();
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
} catch (Throwable throwable) {
resultsRecyclerView.setVisibility(View.GONE);
emptyTextView.setVisibility(View.VISIBLE);
emptyTextView.setText(getString(R.string.error_generic));
}
}
示例5: getCompleteResult
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
public Observable<PointOfInterest> getCompleteResult(final GoogleApiClient mGoogleApiClient, final String id) {
return Observable.create(new Observable.OnSubscribe<PointOfInterest>() {
@Override
public void call(final Subscriber<? super PointOfInterest> subscriber) {
final PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, id);
placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
places.release();
subscriber.onError(null);
} else {
subscriber.onNext(PointOfInterest.fromPlace(places.get(0)));
places.close();
subscriber.onCompleted();
}
}
});
}
});
}
示例6: getPlaceByID
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
public Observable<Place> getPlaceByID(final String placeId) {
return new Observable<Place>() {
@Override
protected void subscribeActual(final Observer<? super Place> observer) {
Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId)
.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
if (places.getStatus().isSuccess()) {
final Place thatPlace = places.get(0);
LatLng queriedLocation = thatPlace.getLatLng();
Log.v("Latitude is", "" + queriedLocation.latitude);
Log.v("Longitude is", "" + queriedLocation.longitude);
observer.onNext(thatPlace.freeze());
}
places.release();
}
});
}
}.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
示例7: onChildAdded
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
final String placeId=dataSnapshot.getKey();
if(placeId!=null)
{
Places.GeoDataApi
.getPlaceById(mGoogleApiClient,placeId)
.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
LatLng location=places.get(0).getLatLng();
//CharSequence userName=places.get(1).getName();
//Toast.makeText(getApplicationContext(),"reached onChildAdded",Toast.LENGTH_SHORT).show();
addPointToView(location);
mMap.addMarker(new MarkerOptions()
.position(location));
//Toast.makeText(getApplicationContext(),"place added",Toast.LENGTH_SHORT).show();
places.release();
}
});
}
}
示例8: onItemClick
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
/*
Retrieve the place ID of the selected item from the Adapter.
The adapter stores each Place suggestion in a AutocompletePrediction from which we
read the place ID and title.
*/
final AutocompletePrediction item = mAdapter.getItem (position);
final String placeId = item.getPlaceId ();
final CharSequence primaryText = item.getPrimaryText (null);
Log.i("", "Autocomplete item selected: " + primaryText);
/*
Issue a request to the Places Geo Data API to retrieve a Place object with additional
details about the place.
*/
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById (mGoogleApiClient, placeId);
placeResult.setResultCallback (mUpdatePlaceDetailsCallback);
Log.i("", "Called getPlaceById to get Place details for " + placeId);
mSearchLocation.setThreshold(1000);
}
示例9: onResult
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onResult (PlaceBuffer places) {
if (!places.getStatus ().isSuccess ()) {
// Request did not statusComplete successfully
Log.e("", "Place query did not statusComplete. Error: " + places.getStatus().toString());
places.release ();
return;
}
// Get the Place object from the buffer.
final Place place = places.get (0);
Log.e("Place", place.getAddress() + "");
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLng(), 16.0f));
Log.i("", "LatLog " + place.getLatLng());
Log.i("", "Place details received: " + place.getName());
places.release();
}
示例10: onResult
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onResult(PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
Log.e(LOG_TAG, "Place query did not complete. Error: " +
places.getStatus().toString());
return;
}
// Selecting the first object buffer.
final Place place = places.get(0);
CharSequence attributions = places.getAttributions();
mNameTextView.setText(Html.fromHtml(place.getName() + ""));
mAddressTextView.setText(Html.fromHtml(place.getAddress() + ""));
mIdTextView.setText(Html.fromHtml(place.getId() + ""));
mPhoneTextView.setText(Html.fromHtml(place.getPhoneNumber() + ""));
mWebTextView.setText(place.getWebsiteUri() + "");
if (attributions != null) {
mAttTextView.setText(Html.fromHtml(attributions.toString()));
}
}
示例11: onItemClick
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
/*
Retrieve the place ID of the selected item from the Adapter.
The adapter stores each Place suggestion in a AutocompletePrediction from which we
read the place ID and title.
*/
final AutocompletePrediction item = mAdapter.getItem(position);
final String placeId = item.getPlaceId();
final CharSequence primaryText = item.getPrimaryText(null);
Log.i(TAG, "Autocomplete item selected: " + primaryText);
/*
Issue a request to the Places Geo Data API to retrieve a Place object with additional
details about the place.
*/
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId);
placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
Toast.makeText(getApplicationContext(), "Clicked: " + primaryText,
Toast.LENGTH_SHORT).show();
Log.i(TAG, "Called getPlaceById to get Place details for " + placeId);
}
示例12: onChildAdded
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
/**
* Act upon new check-outs when they appear.
*/
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String placeId = dataSnapshot.getKey();
if (placeId != null) {
Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId)
.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
LatLng location = places.get(0).getLatLng();
addPointToViewPort(location);
mMap.addMarker(new MarkerOptions().position(location));
places.release();
}
}
);
}
}
示例13: findPlaceById
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
private void findPlaceById( String id ) {
if( TextUtils.isEmpty( id ) || mGoogleApiClient == null || !mGoogleApiClient.isConnected() )
return;
Places.GeoDataApi.getPlaceById( mGoogleApiClient, id ) .setResultCallback( new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if( places.getStatus().isSuccess() ) {
Place place = places.get( 0 );
displayPlace( place );
mPredictTextView.setText( "" );
mAdapter.clear();
}
//Release the PlaceBuffer to prevent a memory leak
places.release();
}
} );
}
示例14: getPlaceById
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
/**
* Returns observable that fetches a place from the Places API using the place ID.
*
* @param placeId id for place
* @return observable that emits places buffer and completes
*/
public Observable<PlaceBuffer> getPlaceById(@Nullable final String placeId) {
return getGoogleApiClientObservable(Places.PLACE_DETECTION_API, Places.GEO_DATA_API)
.flatMap(new Func1<GoogleApiClient, Observable<PlaceBuffer>>() {
@Override
public Observable<PlaceBuffer> call(GoogleApiClient api) {
return fromPendingResult(Places.GeoDataApi.getPlaceById(api, placeId));
}
});
}
示例15: swapPlaces
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
public void swapPlaces(PlaceBuffer newPlaces){
mPlaces = newPlaces;
if (mPlaces!= null)
//force the recyclerview to reload.
this.notifyDataSetChanged();
}