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

项目:Addy-Android    文件:PlacesAPIActivity.java   
private void callPlaceDetectionApi() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
            }
            likelyPlaces.release();
        }
    });
}
项目:Stalker    文件:PlaceFragment.java   
void getCurrentPlace() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(placeApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (int i = 0; i < likelyPlaces.getCount() && i < 5; i++) {
                PlaceEntry place = new PlaceEntry();
                if (likelyPlaces.get(i).getLikelihood() == 0) continue;

                place.setName(likelyPlaces.get(i).getPlace().getName().toString());
                place.setLatLon(likelyPlaces.get(i).getPlace().getLatLng());
                myDataset.add(place);
                mAdapter.notifyItemInserted(myDataset.size() - 1);
            }
            getMapA();
            likelyPlaces.release();
        }
    });
}
项目:AddyHINT17    文件:PlacesAPIActivity.java   
private void callPlaceDetectionApi() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
            }
            likelyPlaces.release();
        }
    });
}
项目:Gps    文件:Gps4Activity.java   
private void callPlaceDetectionApi() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
                display.setText(placeLikelihood.getPlace().getAddress().toString());
                messageSending(placeLikelihood.getPlace().getAddress().toString());
                break;
            }
            likelyPlaces.release();
        }
    });
}
项目:Gps    文件:Gps4Activity.java   
private void callPlaceDetectionApi2(final String ph_number) throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
                display.setText(placeLikelihood.getPlace().getAddress().toString());
                messageSending_individual(ph_number,placeLikelihood.getPlace().getAddress().toString());
                break;
            }
            likelyPlaces.release();
        }
    });
}
项目:Stalker    文件:PlaceFragment.java   
void getCurrentPlace() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(placeApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (int i = 0; i < likelyPlaces.getCount() && i < 5; i++) {
                PlaceEntry place = new PlaceEntry();
                if (likelyPlaces.get(i).getLikelihood() == 0) continue;

                place.setName(likelyPlaces.get(i).getPlace().getName().toString());
                place.setLatLon(likelyPlaces.get(i).getPlace().getLatLng());
                myDataset.add(place);
                mAdapter.notifyItemInserted(myDataset.size() - 1);
            }
            getMapA();
            likelyPlaces.release();
        }
    });
}
项目:PlacesAPI    文件:PlacesAPIActivity.java   
private void callPlaceDetectionApi() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
            }
            likelyPlaces.release();
        }
    });
}
项目:AndroidDemoProjects    文件:MainActivity.java   
private void guessCurrentPlace() {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace( mGoogleApiClient, null );
    result.setResultCallback( new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult( PlaceLikelihoodBuffer likelyPlaces ) {

            PlaceLikelihood placeLikelihood = likelyPlaces.get( 0 );
            String content = "";
            if( placeLikelihood != null && placeLikelihood.getPlace() != null && !TextUtils.isEmpty( placeLikelihood.getPlace().getName() ) )
                content = "Most likely place: " + placeLikelihood.getPlace().getName() + "\n";
            if( placeLikelihood != null )
                content += "Percent change of being there: " + (int) ( placeLikelihood.getLikelihood() * 100 ) + "%";
            mTextView.setText( content );

            likelyPlaces.release();
        }
    });
}
项目:GitHub    文件:ReactiveLocationProvider.java   
/**
 * Returns observable that fetches current place from Places API. To flatmap and auto release
 * buffer to {@link com.google.android.gms.location.places.PlaceLikelihood} observable use
 * {@link DataBufferObservable}.
 *
 * @param placeFilter filter
 * @return observable that emits current places buffer and completes
 */
public Observable<PlaceLikelihoodBuffer> getCurrentPlace(@Nullable final PlaceFilter placeFilter) {
    return getGoogleApiClientObservable(Places.PLACE_DETECTION_API, Places.GEO_DATA_API)
            .flatMap(new Func1<GoogleApiClient, Observable<PlaceLikelihoodBuffer>>() {
                @Override
                public Observable<PlaceLikelihoodBuffer> call(GoogleApiClient api) {
                    return fromPendingResult(Places.PlaceDetectionApi.getCurrentPlace(api, placeFilter));
                }
            });
}
项目:MedicalMe    文件:MapsActivity.java   
/**
 * Adds markers for places nearby the device and turns the My Location feature on or off,
 * provided location permission has been granted.
 */
private void updateMarkers() {
    if (mMap == null) {
        return;
    }

    if (mLocationPermissionGranted) {
        // Get the businesses and other points of interest located
        // nearest to the device's current location.
        @SuppressWarnings("MissingPermission")
        PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
                .getCurrentPlace(mGoogleApiClient, null);
        result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
            @Override
            public void onResult(@NonNull PlaceLikelihoodBuffer likelyPlaces) {
                for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                    // Add a marker for each place near the device's current location, with an
                    // info window showing place information.
                    String attributions = (String) placeLikelihood.getPlace().getAttributions();
                    String snippet = (String) placeLikelihood.getPlace().getAddress();
                    if (attributions != null) {
                        snippet = snippet + "\n" + attributions;
                    }

                    mMap.addMarker(new MarkerOptions()
                            .position(placeLikelihood.getPlace().getLatLng())
                            .title((String) placeLikelihood.getPlace().getName())
                            .snippet(snippet));
                }
                // Release the place likelihood buffer.
                likelyPlaces.release();
            }
        });
    } else {
        mMap.addMarker(new MarkerOptions()
                .position(mDefaultLocation)
                .title(getString(R.string.default_info_title))
                .snippet(getString(R.string.default_info_snippet)));
    }
}
项目:gaso    文件:PlacesHelper.java   
public void isAtGasStationAsync(final CurrentPlaceListener currentPlaceListener) {
    if (!LocationHelper.isLocationPermissionAsked && ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(activity,
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LocationHelper.LOCATION_PERMISSION_REQUEST);
        Log.e("getting location", "NO PERMISSION");
    }
    PendingResult<PlaceLikelihoodBuffer> places = Places.PlaceDetectionApi
            .getCurrentPlace(googleApiClient, null);
    places.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                if (placeLikelihood.getLikelihood() > LIKELIHOOD_ACCEPTABLE) {
                    List<Integer> types = placeLikelihood.getPlace().getPlaceTypes();
                    for (int t : types) {
                        if (t == Place.TYPE_GAS_STATION) {
                            lastStation = new Station(placeLikelihood.getPlace());
                            currentPlaceListener.OnIsAtGasStationResult(lastStation);
                            break;
                        }
                    }
                }
            }
            likelyPlaces.release();
        }
    });
}
项目:MobilAsistan    文件:Konumlar.java   
private void lokasyonCek(final boolean hepsi, final boolean hastahane, final boolean eczane, final boolean cafe, final boolean ibadethane, final boolean okul, final boolean diger) {

        PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
                .getCurrentPlace(mGoogleApiClient, null);
        result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
            @Override
            public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
                for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                    List types=placeLikelihood.getPlace().getPlaceTypes();
                    Log.i("liste", String.format("Place '%s' has likelihood: %g",
                            placeLikelihood.getPlace().getName(),
                            placeLikelihood.getLikelihood()));
                    if(hepsi)
                    konumlar.add(placeLikelihood.getPlace().getName().toString());
                    else{
                        if(hastahane && (types.contains(Place.TYPE_HOSPITAL) || types.contains(Place.TYPE_DOCTOR) ||types.contains(Place.TYPE_DENTIST) || types.contains(Place.TYPE_VETERINARY_CARE)))
                            konumlar.add(placeLikelihood.getPlace().getName().toString());
                        if(eczane && types.contains(Place.TYPE_PHARMACY))
                            konumlar.add(placeLikelihood.getPlace().getName().toString());
                        if(cafe &&( types.contains(Place.TYPE_CAFE) ||(types.contains(Place.TYPE_RESTAURANT) || types.contains(Place.TYPE_NIGHT_CLUB))))
                            konumlar.add(placeLikelihood.getPlace().getName().toString());
                        if(ibadethane && (types.contains(Place.TYPE_MOSQUE) || types.contains(Place.TYPE_CHURCH)))
                            konumlar.add(placeLikelihood.getPlace().getName().toString());
                        if(okul && (types.contains(Place.TYPE_UNIVERSITY) || types.contains(Place.TYPE_SCHOOL)))
                            konumlar.add(placeLikelihood.getPlace().getName().toString());
                        if(diger)
                            konumlar.add(placeLikelihood.getPlace().getName().toString());
                    }

                }
                likelyPlaces.release();
                veriAdaptoru.notifyDataSetChanged();
            }
        });



    }
项目:memoir    文件:ViewActivity.java   
public void getCurrentLocation() {
    try {
        // On Marshmallow request for permissions first
        if (Build.VERSION.SDK_INT >= 23) {
            if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
                        PERMISSION_ACCESS_FINE_LOCATION);
            } else {
                return;
            }
            if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION},
                        PERMISSION_ACCESS_COARSE_LOCATION);
            } else {
                return;
            }
        }

        PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(mGoogleApiClient, null);
        result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
            @Override
            public void onResult(@NonNull PlaceLikelihoodBuffer likelyPlaces) {
                Place place = null;
                float max = 0;
                for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                    float likelihood = placeLikelihood.getLikelihood();
                    if (likelihood > max) {
                        place = placeLikelihood.getPlace();
                        max = placeLikelihood.getLikelihood();
                    }
                }
                if (place == null) {
                    Toast.makeText(getApplicationContext(), R.string.note_location_unable, Toast.LENGTH_SHORT).show();
                } else {
                    note.setLocation(place);
                    refreshLayout();
                }
                likelyPlaces.release();
            }
        });
    } catch (Exception ex) {
        Toast.makeText(getApplicationContext(), R.string.note_location_unable, Toast.LENGTH_SHORT).show();
    }
}