Search in sources :

Example 1 with MapProvider

use of com.peterlaurence.trekadvisor.menu.MapProvider in project TrekAdvisor by peterLaurence.

the class MapViewFragment method onAttach.

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof RequestManageTracksListener && context instanceof RequestManageMarkerListener && context instanceof MapProvider) {
        mRequestManageTracksListener = (RequestManageTracksListener) context;
        mRequestManageMarkerListener = (RequestManageMarkerListener) context;
        mMapProvider = (MapProvider) context;
    } else {
        throw new RuntimeException(context.toString() + " must implement RequestManageTracksListener, MapProvider and LocationProvider");
    }
    /* The Google api client is re-created here as the onAttach method will always be called for
         * a retained fragment.
         */
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this.getActivity().getApplicationContext());
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationCallback = new LocationCallback() {

        @Override
        public void onLocationResult(LocationResult locationResult) {
            for (Location location : locationResult.getLocations()) {
                onLocationReceived(location);
            }
        }
    };
}
Also used : MapProvider(com.peterlaurence.trekadvisor.menu.MapProvider) LocationRequest(com.google.android.gms.location.LocationRequest) LocationCallback(com.google.android.gms.location.LocationCallback) LocationResult(com.google.android.gms.location.LocationResult) Location(android.location.Location)

Aggregations

Location (android.location.Location)1 LocationCallback (com.google.android.gms.location.LocationCallback)1 LocationRequest (com.google.android.gms.location.LocationRequest)1 LocationResult (com.google.android.gms.location.LocationResult)1 MapProvider (com.peterlaurence.trekadvisor.menu.MapProvider)1