本文整理汇总了Java中com.google.android.gms.location.places.PlaceBuffer类的典型用法代码示例。如果您正苦于以下问题:Java PlaceBuffer类的具体用法?Java PlaceBuffer怎么用?Java PlaceBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlaceBuffer类属于com.google.android.gms.location.places包,在下文中一共展示了PlaceBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:PlacesResultActivity.java
示例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);
}
}
开发者ID:samagra14,项目名称:Shush,代码行数:24,代码来源:Geofencing.java
示例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();
}
});
}
开发者ID:samagra14,项目名称:Shush,代码行数:23,代码来源:MainActivity.java
示例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));
}
}
开发者ID:Mun0n,项目名称:MADBike,代码行数:26,代码来源:SearchActivity.java
示例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();
}
}
});
}
});
}
开发者ID:sathishmscict,项目名称:Pickr,代码行数:23,代码来源:DataManager.java
示例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());
}
开发者ID:aliumujib,项目名称:Nibo,代码行数:24,代码来源:LocationRepository.java
示例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();
}
});
}
}
开发者ID:agarwal-akash,项目名称:BonAppetit_Android-Project,代码行数:25,代码来源:MapsActivity.java
示例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);
}
开发者ID:blessingoraz,项目名称:Akwukwo,代码行数:24,代码来源:SearchLocationActivity.java
示例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();
}
开发者ID:blessingoraz,项目名称:Akwukwo,代码行数:23,代码来源:SearchLocationActivity.java
示例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()));
}
}
开发者ID:Truiton,项目名称:PlaceAPIAutocomplete,代码行数:21,代码来源:MainActivity.java
示例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);
}
开发者ID:David-Hackro,项目名称:ExamplesAndroid,代码行数:26,代码来源:MainActivity.java
示例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();
}
}
);
}
}
开发者ID:googlesamples,项目名称:io2015-codelabs,代码行数:22,代码来源:MapsActivity.java
示例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();
}
} );
}
开发者ID:Lakkichand,项目名称:AndroidDemoProjects,代码行数:20,代码来源:MainActivity.java
示例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));
}
});
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:ReactiveLocationProvider.java
示例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();
}
开发者ID:samagra14,项目名称:Shush,代码行数:8,代码来源:PlaceListAdapter.java
示例16: onItemClick
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
AnalyticsManager.getInstance().trackSearch();
final AutocompletePrediction item = mAdapter.getItem(position);
final String placeId = item.getPlaceId();
final CharSequence primaryText = item.getPrimaryText(null);
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId);
placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
}
开发者ID:Mun0n,项目名称:MADBike,代码行数:11,代码来源:SearchActivity.java
示例17: onItemClick
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
UIUtils.hideKeyboard(AutoCompleteLocation.this.getContext(), AutoCompleteLocation.this);
final AutocompletePrediction item = mAutoCompleteAdapter.getItem(position);
if (item != null) {
final String placeId = item.getPlaceId();
PendingResult<PlaceBuffer> placeResult =
Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId);
placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
}
}
开发者ID:jotaramirez90,项目名称:AutocompleteLocation,代码行数:11,代码来源:AutoCompleteLocation.java
示例18: onResult
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override public void onResult(@NonNull PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
places.release();
return;
}
final Place place = places.get(0);
if (mAutoCompleteLocationListener != null) {
mAutoCompleteLocationListener.onItemSelected(place);
}
places.release();
}
开发者ID:jotaramirez90,项目名称:AutocompleteLocation,代码行数:12,代码来源:AutoCompleteLocation.java
示例19: onItemClick
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final AutocompletePrediction item = mAdapter.getItem(position);
final String placeId = item.getPlaceId();
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId);
placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
}
开发者ID:agusibrahim,项目名称:go-jay,代码行数:9,代码来源:PlaceAutoCompleteHelper.java
示例20: onResult
import com.google.android.gms.location.places.PlaceBuffer; //导入依赖的package包/类
@Override
public void onResult(PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
if (callback != null) callback.onSuggestFail(places.getStatus());
places.release();
return;
}
final Place place = places.get(0);
if (callback != null) callback.onSuggestResult(place, myact);
places.release();
}
开发者ID:agusibrahim,项目名称:go-jay,代码行数:12,代码来源:PlaceAutoCompleteHelper.java
注:本文中的com.google.android.gms.location.places.PlaceBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论