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

项目:GitHub    文件:PlacesResultActivity.java   
@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();
                }
            }));
}
项目:Shush    文件:Geofencing.java   
/**
 * 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);
    }
}
项目:Shush    文件:MainActivity.java   
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();
        }
    });
}
项目:MADBike    文件:SearchActivity.java   
@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));
    }
}
项目:Pickr    文件:DataManager.java   
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();
                    }
                }
            });
        }
    });
}
项目:Nibo    文件:LocationRepository.java   
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());
}
项目:BonAppetit_Android-Project    文件:MapsActivity.java   
@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();
                    }
                });
    }

}
项目:Akwukwo    文件:SearchLocationActivity.java   
@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);
}
项目:Akwukwo    文件:SearchLocationActivity.java   
@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();


}
项目:PlaceAPIAutocomplete    文件:MainActivity.java   
@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()));
    }
}
项目:ExamplesAndroid    文件:MainActivity.java   
@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);
}
项目:io2015-codelabs    文件:MapsActivity.java   
/**
 * 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();
                           }
                       }
                );
    }
}
项目:AndroidDemoProjects    文件:MainActivity.java   
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();
       }
   } );
}
项目:GitHub    文件:ReactiveLocationProvider.java   
/**
 * 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));
                }
            });
}
项目:Shush    文件:PlaceListAdapter.java   
public void swapPlaces(PlaceBuffer newPlaces){
    mPlaces = newPlaces;
    if (mPlaces!= null)
        //force the recyclerview to reload.
        this.notifyDataSetChanged();

}
项目:MADBike    文件:SearchActivity.java   
@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);
}
项目:AutocompleteLocation    文件:AutoCompleteLocation.java   
@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);
  }
}
项目:AutocompleteLocation    文件:AutoCompleteLocation.java   
@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();
}
项目:go-jay    文件:PlaceAutoCompleteHelper.java   
@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);
}
项目:go-jay    文件:PlaceAutoCompleteHelper.java   
@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();
     }
项目:moneytracking    文件:NewItemActivity.java   
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final PlaceAdapter.PlaceAutocomplete item = mPlaceArrayAdapter.getItem(position);
    final String placeId = String.valueOf(item.placeId);
    PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId);
    placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
}
项目:moneytracking    文件:NewItemActivity.java   
@Override
public void onResult(PlaceBuffer places) {
    if (!places.getStatus().isSuccess()) {
        return;
    }
    place = places.get(0);

}
项目:moneytracking    文件:EditActivity.java   
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final PlaceAdapter.PlaceAutocomplete item = mPlaceArrayAdapter.getItem(position);
    final String placeId = String.valueOf(item.placeId);
    PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId);
    placeResult.setResultCallback(mUpdatePlaceDetailsCallback);

}
项目:moneytracking    文件:EditActivity.java   
@Override
public void onResult(PlaceBuffer places) {
    if (!places.getStatus().isSuccess()) {
        return;
    }
    // Selecting the first object buffer.
    place = places.get(0);
    addLocation.setText(place.getAddress().toString());
    return;


}
项目:movemate_android    文件:CreateRouteFragment.java   
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    InputMethodManager in = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    in.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);

    final PlaceArrayAdapter.PlaceAutocomplete item = mPlaceArrayAdapter.getItem(position);
    final String placeId = String.valueOf(item.placeId);
    final_placeId = placeId;
    Log.i(LOG_TAG, final_placeId);
    PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
            .getPlaceById(mGoogleApiClient, placeId);
    placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
}
项目:movemate_android    文件:CreateRouteFragment.java   
@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();

}
项目:AutocompleteLocation    文件:AutoCompleteLocation.java   
@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);
  }
}
项目:AutocompleteLocation    文件:AutoCompleteLocation.java   
@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();
}
项目:RxWeather    文件:WeatherActivity.java   
private void loadPlaceInfo(Address address) {
    Places.GeoDataApi.getPlaceById(mGoogleApiClient, address.getPlaceId())
            .setResultCallback(new ResultCallback<PlaceBuffer>() {
                @Override
                public void onResult(@NonNull PlaceBuffer places) {
                    if (places.getStatus().isSuccess() && places.getCount() > 0) {
                        Place place = places.get(0);
                        LatLng latLng = place.getLatLng();
                        Subscription subscription = getWeatherForecast(latLng.latitude, latLng.longitude)
                                .subscribe(new Subscriber<WeatherData>() {
                                    @Override
                                    public void onCompleted() {
                                        Timber.d("onCompleted()");
                                    }

                                    @Override
                                    public void onError(Throwable e) {
                                        handleError(e);
                                    }

                                    @Override
                                    public void onNext(WeatherData weatherData) {
                                        updateUi(weatherData);
                                    }
                                });
                        mCompositeSubscription.add(subscription);
                    } else {
                        Timber.e("Place not found");
                    }
                    places.release();
                }
            });
}
项目:Airbnb-Android-Google-Map-View    文件:SearchPlaceOnMapActivity.java   
@Override
public void onResult(PlaceBuffer places) {
    if (!places.getStatus().isSuccess()) {
        places.release();
        return;
    }
    // Get the Place object from the buffer.
    final Place place = places.get(0);
    hideKeyboard();
    mLatitude=String.valueOf(place.getLatLng().latitude);
    mLongitude=String.valueOf(place.getLatLng().longitude);
    LatLng newLatLngTemp = new LatLng(place.getLatLng().latitude, place.getLatLng().longitude);
    // LatLng centerLatLng=new LatLng(mMap.getCameraPosition().target.latitude,mMap.getCameraPosition().target.longitude);
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(newLatLngTemp, 15f));
}
项目:Airbnb-Android-Google-Map-View    文件:SearchPlaceOnMapActivity.java   
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    final PlaceAutocompleteAdapter.PlaceAutocomplete item = mAdapter.getItem(position);
    final String placeId = String.valueOf(item.placeId);


    PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
            .getPlaceById(mGoogleApiClient, placeId);
    placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
}
项目:PlaceAPIAutocomplete    文件:MainActivity.java   
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final PlaceArrayAdapter.PlaceAutocomplete item = mPlaceArrayAdapter.getItem(position);
    final String placeId = String.valueOf(item.placeId);
    Log.i(LOG_TAG, "Selected: " + item.description);
    PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
            .getPlaceById(mGoogleApiClient, placeId);
    placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
    Log.i(LOG_TAG, "Fetching details for ID: " + item.placeId);
}
项目:gaso    文件:PlacesHelper.java   
public void findStationByID(String placeId, final StationFoundListener stationFoundListener){
    Places.GeoDataApi.getPlaceById(googleApiClient, placeId)
            .setResultCallback(new ResultCallback<PlaceBuffer>() {
                @Override
                public void onResult(PlaceBuffer places) {
                    if (places.getStatus().isSuccess() && places.getCount() > 0) {
                        Station station = new Station(places.get(0));
                        stationFoundListener.OnFindStationResult(station);
                    } else {
                        stationFoundListener.OnFindStationResult(null);
                    }
                    places.release();
                }
            });
}
项目:ExamplesAndroid    文件:MainActivity.java   
@Override
public void onResult(PlaceBuffer places) {
    if (!places.getStatus().isSuccess()) {
        // Request did not complete successfully
        Log.e(TAG, "Place query did not complete. Error: " + places.getStatus().toString());
        places.release();
        return;
    }
    // Get the Place object from the buffer.
    final Place place = places.get(0);

    // Format details of the place for display and show it in a TextView.
    mPlaceDetailsText.setText(formatPlaceDetails(getResources(), place.getName(),
            place.getId(), place.getAddress(), place.getPhoneNumber(),
            place.getWebsiteUri()));

    // Display the third party attributions if set.
    final CharSequence thirdPartyAttribution = places.getAttributions();
    if (thirdPartyAttribution == null) {
        mPlaceDetailsAttribution.setVisibility(View.GONE);
    } else {
        mPlaceDetailsAttribution.setVisibility(View.VISIBLE);
        mPlaceDetailsAttribution.setText(Html.fromHtml(thirdPartyAttribution.toString()));
    }

    Log.i(TAG, "Place details received: " + place.getName());

    places.release();
}
项目:Shush    文件:PlaceListAdapter.java   
/**
 * Constructor to initialise the adapter using context and the db cursor.
 * @param mContext {@link Context} Passing in the context from the activity.
 * @param mPlaces {@link PlaceBuffer} A buffer for storing a list of places selected by the user.
 */
public PlaceListAdapter(Context mContext,PlaceBuffer mPlaces) {
    this.mContext = mContext;
    this.mPlaces = mPlaces;

}
项目:amos-ss15-proj2    文件:JoinSearchFragment.java   
@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 PlaceAutocomplete object from which we
     read the place ID.
      */
    final PlaceAutocompleteAdapter.PlaceAutocomplete item = adapter.getItem(position);
    final String placeId = String.valueOf(item.placeId);

    /*
     Issue a request to the Places Geo Data API to retrieve a Place object with additional
      details about the place.
      */
    progressBar.setVisibility(View.VISIBLE);
    PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi.getPlaceById(googleApiClient, placeId);
    placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
        @Override
        public void onResult(PlaceBuffer places) {
            if (!places.getStatus().isSuccess()) {
                // Request did not complete successfully
                places.release();
                return;
            }

            Place place;
            try {
                place = places.get(0);
            } catch (IllegalStateException e) {
                places.release();
                return;
            }
            lastSelected = new org.croudtrip.db.Place();
            lastSelected.setId(place.getId());
            lastSelected.setDescription(place.getAddress() + "");
            tv_address.setText(place.getAddress());
            progressBar.setVisibility(View.GONE);


            places.release();

            InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        }
    });

    Toast.makeText(getActivity().getApplicationContext(), "Clicked: " + item.description, Toast.LENGTH_SHORT).show();
}
项目:amos-ss15-proj2    文件:OfferTripFragment.java   
@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 PlaceAutocomplete object from which we
     read the place ID.
      */
    final PlaceAutocompleteAdapter.PlaceAutocomplete item = adapter.getItem(position);
    final String placeId = String.valueOf(item.placeId);

    /*
     Issue a request to the Places Geo Data API to retrieve a Place object with additional
      details about the place.
      */
    progressBar.setVisibility(View.VISIBLE);
    PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi.getPlaceById(googleApiClient, placeId);
    placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
        @Override
        public void onResult(PlaceBuffer places) {
            if (!places.getStatus().isSuccess()) {
                // Request did not complete successfully
                places.release();
                return;
            }

            Place place;
            try {
                place = places.get(0);
            } catch (IllegalStateException e) {
                places.release();
                return;
            }
            lastSelected = new org.croudtrip.db.Place();
            lastSelected.setId(place.getId());
            lastSelected.setDescription(place.getAddress() + "");
            tv_address.setText(place.getAddress());
            progressBar.setVisibility(View.GONE);

            places.release();

            InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        }
    });

    Toast.makeText(getActivity().getApplicationContext(), "Clicked: " + item.description, Toast.LENGTH_SHORT).show();
}
项目:voyager2-android    文件:PlaceAutoCompleteOnItemClickListener.java   
public PlaceAutoCompleteOnItemClickListener(GoogleApiClient googleApiClient, PlaceAutoCompleteAdapter adapter, ResultCallback<PlaceBuffer> resultCallback) {
    this.googleApiClient = googleApiClient;
    this.placeAutoCompleteAdapter = adapter;
    this.resultCallback = resultCallback;
}