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);
}
}
};
}
Aggregations