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

项目:2017NASA_NCTUBeach    文件:LocationSelectActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            Intent intent = new Intent(this, InfoActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra("name", place.getName());
            intent.putExtra("lat", place.getLatLng().latitude);
            intent.putExtra("lng", place.getLatLng().longitude);
            startActivity(intent);
            finish();
        } else finish();
    }

}
项目: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   
/***
 * Called when the Place Picker Activity returns back with a selected place (or after canceling)
 *
 * @param requestCode The request code passed when calling startActivityForResult
 * @param resultCode  The result code specified by the second activity
 * @param data        The Intent that carries the result data.
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode==PLACE_PICKER_REQUEST&&resultCode==RESULT_OK){
        Place place = PlacePicker.getPlace(this,data);
        if (place==null){
            Log.i(LOG_TAG,"No place selected");
            return;
        }
        String placeName = place.getName().toString();
        String placeAddress = place.getAddress().toString();
        String placeId = place.getId();

        ContentValues values = new ContentValues();
        values.put(PlacesContract.PlaceEntry.COLUMN_PLACE_ID,placeId);
        getContentResolver().insert(PlacesContract.PlaceEntry.CONTENT_URI,values);
        refreshPlacesData();
    }
}
项目: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));
    }
}
项目:civify-app    文件:NavigateFragment.java   
private void handleSearch(int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        Place place = PlaceAutocomplete.getPlace(getActivity(), data);
        Location loc = LocationAdapter.getLocation(place.getLatLng());
        try {
            CivifyMap.getInstance().disableLocation();
            CivifyMap.getInstance().setAutoCenter(false);
            mLastZoom = CivifyMap.getInstance().getCurrentCameraPosition().zoom;

            CivifyMap.getInstance().center(loc, CivifyMap.DEFAULT_ZOOM, true);
            mSarchCenterSnackbar = Snackbar.make(getView(),
                    getString(R.string.search_disable_center), Snackbar.LENGTH_INDEFINITE);
            mSarchCenterSnackbar.show();
        } catch (MapNotLoadedException ignore) {
            Snackbar.make(getView(), getString(R.string.error_ocurred),
                    Snackbar.LENGTH_SHORT).show();
        }
    } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
        Snackbar.make(getView(), getString(R.string.error_ocurred),
                Snackbar.LENGTH_SHORT).show();
    }
}
项目:go-jay    文件:MainActivity.java   
@Override
public void onSuggestResult(final Place place, final AutoCompleteTextView act) {
    final LatLng placelatlng=place.getLatLng();
    if (!isNavigationReady() && (addr_from.getText().length() < 1 || addr_to.getText().length() < 1))
        gmaps.animateCamera(CameraUpdateFactory.newLatLng(place.getLatLng()), 1000, new GoogleMap.CancelableCallback(){
                @Override
                public void onFinish() {
                    setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
                }

                @Override
                public void onCancel() {
                    setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
                }
            });
    else setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
}
项目:AppGoogleMaps    文件:DirectionsDetailFragment.java   
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode){
        case PLACE_AUTOCOMPLETE_REQUEST_CODE:
            if (resultCode == RESULT_OK) {
                Place place = PlaceAutocomplete.getPlace(getActivity(), data);
                showToast(place.getAddress().toString());
                Log.i("TAG", "Place: " + place.getName());
            } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
                Status status = PlaceAutocomplete.getStatus(getActivity(), data);
                // TODO: Handle the error.
                Log.i("TAG", status.getStatusMessage());
                showToast(status.getStatusMessage());
            } else if (resultCode == RESULT_CANCELED) {
                // The user canceled the operation.
                showToast("Operation canceled");
            }
            break;
    }
}
项目:ElephantAsia    文件:AddProfilFragment.java   
/**
 * Set current location from map
 * TODO: Faire mieux la difference entre une location exacte et une
 *
 * @param location the location returned from the map picker
 */
public void setCurrentLocation(Intent data) {
  final Place place = PlacePicker.getPlace(getActivity(), data);
  Geocoder geocoder = new Geocoder(getActivity());

  try {
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
    elephant.currentLoc.cityName = addresses.get(0).getAddressLine(0);
    if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
      elephant.currentLoc.districtName = addresses.get(0).getSubAdminArea();
    }
    elephant.currentLoc.provinceName = addresses.get(0).getAdminArea();
  } catch (IOException e) {
    e.printStackTrace();
  }

  currentLocation.setText(elephant.currentLoc.format());
}
项目:ElephantAsia    文件:AddProfilFragment.java   
/**
 * Set birth location from map
 *
 * @param location the location returned from the map picker
 */
public void setBirthLocation(Intent data) {
  final Place place = PlacePicker.getPlace(getActivity(), data);
  Geocoder geocoder = new Geocoder(getActivity());

  try {
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
    elephant.birthLoc.cityName = addresses.get(0).getAddressLine(0);
    if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
      elephant.birthLoc.districtName = addresses.get(0).getSubAdminArea();
    }
    elephant.birthLoc.provinceName = addresses.get(0).getAdminArea();
  } catch (IOException e) {
    e.printStackTrace();
  }

  birthLocation.setText(elephant.birthLoc.format());
}
项目:ElephantAsia    文件:AddRegistrationFragment.java   
public void setRegistrationLocation(Intent data) {

    final Place place = PlacePicker.getPlace(getActivity(), data);
    Geocoder geocoder = new Geocoder(getActivity());

    try {
      List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
      elephant.registrationLoc.cityName = addresses.get(0).getAddressLine(0);
      if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
        elephant.registrationLoc.districtName = addresses.get(0).getSubAdminArea();
      }
      elephant.registrationLoc.provinceName = addresses.get(0).getAdminArea();
    } catch (IOException e) {
      e.printStackTrace();
    }

    registrationLocation.setText(elephant.registrationLoc.format());
  }
项目:ElephantAsia    文件:EditRegistrationFragment.java   
public void setRegistrationLocation(Intent data) {

    final Place place = PlacePicker.getPlace(getActivity(), data);
    Geocoder geocoder = new Geocoder(getActivity());

    try {
      List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
      elephant.registrationLoc.cityName = addresses.get(0).getAddressLine(0);
      if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
        elephant.registrationLoc.districtName = addresses.get(0).getSubAdminArea();
      }
      elephant.registrationLoc.provinceName = addresses.get(0).getAdminArea();
    } catch (IOException e) {
      e.printStackTrace();
    }

    registrationLocation.setText(elephant.registrationLoc.format());
  }
项目:ElephantAsia    文件:EditProfilFragment.java   
/**
 * Set current location from map
 * TODO: Faire mieux la difference entre une location exacte et une
 *
 * @param location the location returned from the map picker
 */
public void setCurrentLocation(Intent data) {
  final Place place = PlacePicker.getPlace(getActivity(), data);
  Geocoder geocoder = new Geocoder(getActivity());

  try {
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
    elephant.currentLoc.cityName = addresses.get(0).getAddressLine(0);
    if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
      elephant.currentLoc.districtName = addresses.get(0).getSubAdminArea();
    }
    elephant.currentLoc.provinceName = addresses.get(0).getAdminArea();
  } catch (IOException e) {
    e.printStackTrace();
  }

  currentLocation.setText(elephant.currentLoc.format());
}
项目:ElephantAsia    文件:EditProfilFragment.java   
/**
 * Set birth location from map
 *
 * @param location the location returned from the map picker
 */
public void setBirthLocation(Intent data) {
  final Place place = PlacePicker.getPlace(getActivity(), data);
  Geocoder geocoder = new Geocoder(getActivity());

  try {
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
    elephant.birthLoc.cityName = addresses.get(0).getAddressLine(0);
    if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
      elephant.birthLoc.districtName = addresses.get(0).getSubAdminArea();
    }
    elephant.birthLoc.provinceName = addresses.get(0).getAdminArea();
  } catch (IOException e) {
    e.printStackTrace();
  }

  birthLocation.setText(elephant.birthLoc.format());
}
项目:bikedeboa-android    文件:MapActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            // Move camera to that place and add normal marker
            Place place = PlaceAutocomplete.getPlace(this, data);
            this.googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLng(), 17), 1000, null);
            this.googleMap.addMarker(new MarkerOptions().position(place.getLatLng()));
            // Set text on "edit text"
            binding.placeSearch.setText(place.getName());
        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(this, data);
            Log.w(TAG, status.getStatusMessage());
        } else if (resultCode == RESULT_CANCELED) {
            // The user canceled the operation -- clear text
            binding.placeSearch.setText("");
        }
    }
}
项目:mobile-app-dev-book    文件:NewJournalActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getAddress());
            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
项目:mobile-app-dev-book    文件:NewJournalActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.location = pl.getName().toString();
            currentTrip.lat = pl.getLatLng().latitude;
            currentTrip.lng = pl.getLatLng().longitude;
            currentTrip.placeId = pl.getId();

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
项目:mobile-app-dev-book    文件:NewJournalActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.setLocation(pl.getName().toString());
            currentTrip.setLat(pl.getLatLng().latitude);
            currentTrip.setLng(pl.getLatLng().longitude);
            currentTrip.setPlaceId(pl.getId());

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
项目:mobile-app-dev-book    文件:NewJournalActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.setLocation(pl.getName().toString());
            currentTrip.setLat(pl.getLatLng().latitude);
            currentTrip.setLng(pl.getLatLng().longitude);
            currentTrip.setPlaceId(pl.getId());

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
项目:mobile-app-dev-book    文件:NewJournalActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.setLocation(pl.getName().toString());
            currentTrip.setLat(pl.getLatLng().latitude);
            currentTrip.setLng(pl.getLatLng().longitude);
            currentTrip.setPlaceId(pl.getId());

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
项目:mobile-app-dev-book    文件:TripEditorActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.setLocation(pl.getName().toString());
            currentTrip.setLat(pl.getLatLng().latitude);
            currentTrip.setLng(pl.getLatLng().longitude);
            currentTrip.setPlaceId(pl.getId());

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
项目:mobile-app-dev-book    文件:TripEditorActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.setLocation(pl.getName().toString());
            currentTrip.setLat(pl.getLatLng().latitude);
            currentTrip.setLng(pl.getLatLng().longitude);
            currentTrip.setPlaceId(pl.getId());

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
项目: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());
}
项目:Nibo    文件:NiboPickerFragment.java   
protected void getPlaceDetailsByID(String placeId) {
    mLocationRepository.getPlaceByID(placeId).subscribe(new Consumer<Place>() {
        @Override
        public void accept(@NonNull Place place) throws Exception {
            addSingleMarkerToMap(place.getLatLng());
        }
    }
    , new Consumer<Throwable>() {
        @Override
        public void accept(@NonNull Throwable throwable) throws Exception {
            Log.e(TAG, throwable.getMessage());
        }
    }

    );
}
项目:Nibo    文件:NiboOriginDestinationPickerFragment.java   
protected void getPlaceDetailsByID(final NiboSearchSuggestionItem searchSuggestionItem) {
    mLocationRepository.getPlaceByID(searchSuggestionItem.getPlaceID()).subscribe(new Consumer<Place>() {
        @Override
        public void accept(@io.reactivex.annotations.NonNull Place place) throws Exception {
            hideLoading();
            closeSuggestions();
            if (mRoundedIndicatorOrigin.isChecked()) {
                mSelectedOriginDestination.setOriginItem(searchSuggestionItem);
                mSelectedOriginDestination.setOriginLatLng(place.getLatLng());
                addOriginMarker(place.getLatLng());
            }
            if (mRoundedIndicatorDestination.isChecked()) {
                mSelectedOriginDestination.setDestinationItem(searchSuggestionItem);
                mSelectedOriginDestination.setDestinationLatLng(place.getLatLng());
                addDestinationMarker(place.getLatLng());
            }
        }
    });
}
项目:directly    文件:ToiletListFragment.java   
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    authorizer.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == LOCATION_ENABLE_REQUEST_CODE) {
            new Handler().post(() -> {
                toiletListPresenter.locationEnabledSuccess();
            });
        }
        if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
            Place place = PlaceAutocomplete.getPlace(getActivity(), data);
            toiletListPresenter.citySelected(place);
        }
    }


}
项目:cast-dashboard-android-app    文件:WeatherSettings.java   
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            Place place = PlaceAutocomplete.getPlace(getContext(), data);
            Log.i(MainActivity.TAG, "Place: " + place.getName());


            weatherLat.update(place.getLatLng().latitude);
            weatherLng.update(place.getLatLng().longitude);
            weatherCity.update(place.getName().toString());

            sWeatherCity.setSubHeaderText(weatherCity.value);

            // don't change the order of the following two lines
            updateWidgetProperty("lat", weatherLat.value);
            updateWidgetProperty("lng", weatherLng.value);

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(getContext(), data);
            // TODO: Handle the error.
            Log.i(MainActivity.TAG, status.getStatusMessage());

        }
    }
}
项目:Privy    文件:MainActivity.java   
private void requestNewPrivy(Place placeToAdd) {
    PostPrivyRequest postdata = new PostPrivyRequest();
    Location loc = new Location();
    loc.setLat(placeToAdd.getLatLng().latitude);
    loc.setLng(placeToAdd.getLatLng().longitude);
    postdata.setLocation(loc);
    postdata.setAccuracy(50);
    postdata.setName(getString(R.string.toilet_name_default));
    postdata.setAddress(placeToAdd.getAddress().toString());
    ArrayList<String> types = new ArrayList<String>();
    types.add(getString(R.string.types_default));
    postdata.setTypes(types);
    postdata.setAddress(mSharedPreferences.getString(EMAIL, ""));
    postdata.setLanguage(getString(R.string.language_default));
    new NetworkRequest(this, postdata).postRequest();
}
项目:protrip    文件:MainActivity.java   
@Override
public void onPlaceSelected(Place place) {
    Log.i(TAG, "Place Selected: " + place.getName());
    final String cityId = String.valueOf(place.getId());
    final String cityName = String.valueOf(place.getName());
    final String cityLat = String.valueOf(place.getLatLng().latitude);
    final String cityLng = String.valueOf(place.getLatLng().longitude);

    Intent intent = new Intent(this, CityActivity.class);
    intent.putExtra("cityId", cityId);
    intent.putExtra("cityName", cityName);
    intent.putExtra("cityLat", cityLat);
    intent.putExtra("cityLng", cityLng);
    startActivity(intent);

}
项目:androidprojectbase    文件:PlacesAutoCompleteSample.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    //autocompleteFragment.onActivityResult(requestCode, resultCode, data);
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place place = PlaceAutocomplete.getPlace(this, data);
            Log.i("1", "Place:" + place.toString());
        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(this, data);
            Log.i("1", status.getStatusMessage());
        } else if (requestCode == RESULT_CANCELED) {

        }
    }
}
项目:LivePokemonFinder    文件:MainActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_LOCATION) {
        final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);
        if (resultCode == Activity.RESULT_OK) {
            Toast.makeText(getApplicationContext(), R.string.location_enabled, Toast.LENGTH_LONG).show();
            startLocationUpdates();
        } else {
            Toast.makeText(getApplicationContext(), "Loc is still off,", Toast.LENGTH_LONG).show();
        }
    } else if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            double lat = place.getLatLng().latitude;
            double lon = place.getLatLng().longitude;
            setMyLocationToSharePref((float) lat, (float) lon);
            setMyAddress(this, place.getAddress().toString());
            Location newLoc = new Location("");
            newLoc.setLatitude(lat);
            newLoc.setLongitude(lon);
            EventBus.getDefault().post(newLoc);

        }
    }
}
项目:react-native-google-place-picker    文件:RNGooglePlacePickerModule.java   
public void onActivityResult(final Activity activity, final int requestCode, final int resultCode, final Intent data) {
    if (mCallback == null || requestCode != REQUEST_PLACE_PICKER) {
        return;
    }
    response = Arguments.createMap();
    if (resultCode == 2) {
        response.putString("error", "Google Maps not setup correctly. Did you forget the API key, or enabling the Places API for Android?");
        mCallback.invoke(response);
    } else if (resultCode == Activity.RESULT_OK) {
        final Place place = PlacePicker.getPlace(data, reactContext);
        final CharSequence address = place.getAddress();
        final LatLng coordinate = place.getLatLng();
        final CharSequence name = place.getName();
        final CharSequence id = place.getId();
        response.putString("address", address.toString());
        response.putDouble("latitude", coordinate.latitude);
        response.putDouble("longitude", coordinate.longitude);
        response.putString("name", name.toString());
        response.putString("google_id", id.toString());
        mCallback.invoke(response);
    } else {
        response.putBoolean("didCancel", true);
        mCallback.invoke(response);
        return;
    }
}
项目:PlacePicker    文件:PlacePickerActivity.java   
@Override
protected void onActivityResult(int requestCode,
                                int resultCode, Intent data) {

    if (requestCode == PLACE_PICKER_REQUEST
            && resultCode == Activity.RESULT_OK) {

        final Place place = PlacePicker.getPlace(this, data);
        final CharSequence name = place.getName();
        final CharSequence address = place.getAddress();
        String attributions = (String) place.getAttributions();
        if (attributions == null) {
            attributions = "";
        }

        mName.setText(name);
        mAddress.setText(address);
        mAttributions.setText(Html.fromHtml(attributions));

    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
项目: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()));
    }
}
项目:gaso    文件:ExpensesRegisterActivity.java   
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(this, data);
            try
            {
                stationSelected = new Station(place);
                inputStation.setText(place.getName());
            }
            catch (IllegalArgumentException e)
            {
                String toastMsg = String.format("Ops, parece que %s não é um posto. Tente novamente.", place.getName());
                Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
            }
        }
    }
}
项目:gaso    文件:Station.java   
public Station(Place place){
    List<Integer> types = place.getPlaceTypes();
    boolean isGasStation = false;
    for (Integer i: types){
        if(i==Place.TYPE_GAS_STATION){
            isGasStation = true;
            break;
        }
    }
    if(isGasStation){
        id = place.getId();
        name = place.getName().toString();
        address = place.getAddress().toString();
        phoneNumber = place.getPhoneNumber().toString();
        Location l = new Location(place.getLatLng().latitude,place.getLatLng().longitude);
        location = l;
        generalRate = place.getRating();
        moneyRate = place.getPriceLevel();
    } else {
        throw new IllegalArgumentException("Place is not a gas station.");
    }
}
项目:compass-project    文件:CompassActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_PLACE_PICKER) {
        // This result is from the PlacePicker dialog.

        if (resultCode == Activity.RESULT_OK) {
            // retrieve latitude and longitude from result data
            final Place place = PlacePicker.getPlace(data, this);
            LatLng latLng = place.getLatLng();
            Log.i(TAG, "Lat: " + latLng.latitude + " Lon: " + latLng.longitude);

            onLocationPicked(latLng);
        }
    } else if (requestCode == REQUEST_RESOLVE_ERROR) {
        // This result is from the google play services error resolution intent

        resolvingError = false;
        if (resultCode == RESULT_OK) {
            Snackbar.make(snackbarCoordinator, R.string.resolution_successful,
                    Snackbar.LENGTH_LONG).show();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
项目:amos-ss15-proj2    文件:JoinSearchFragment.java   
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    // The user has selected a place. Extract the location
    if (requestCode == REQUEST_PLACE_PICKER && resultCode == Activity.RESULT_OK) {
        Place place = PlacePicker.getPlace(data, getActivity());
        Location l = new Location("placePicker");
        l.setLatitude(place.getLatLng().latitude);
        l.setLongitude(place.getLatLng().longitude);
        specifiedLocation = l;

        btn_join.setEnabled(true);
        //loadLocationLayout.setVisibility(View.VISIBLE);
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
项目:android-play-places    文件:MainActivity.java   
/**
 * Callback invoked when a place has been selected from the PlaceAutocompleteFragment.
 */
@Override
public void onPlaceSelected(Place place) {
    Log.i(TAG, "Place Selected: " + place.getName());

    // Format the returned place's details and display them in the TextView.
    mPlaceDetailsText.setText(formatPlaceDetails(getResources(), place.getName(), place.getId(),
            place.getAddress(), place.getPhoneNumber(), place.getWebsiteUri()));

    CharSequence attributions = place.getAttributions();
    if (!TextUtils.isEmpty(attributions)) {
        mPlaceAttribution.setText(Html.fromHtml(attributions.toString()));
    } else {
        mPlaceAttribution.setText("");
    }
}