add npe checks

This commit is contained in:
MadWasp79 2020-01-29 11:25:05 +02:00
parent 5404f626ec
commit 2481142f0b
2 changed files with 8 additions and 10 deletions

View file

@ -445,9 +445,7 @@ public class TargetPointsHelper {
Location lastKnownLocation = ctx.getLocationProvider().getLastKnownLocation();
LatLon latLon = lastKnownLocation != null ?
new LatLon(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()) : null;
if (latLon != null) {
routingHelper.checkAndUpdateStartLocation(latLon);
}
routingHelper.checkAndUpdateStartLocation(latLon);
setMyLocationPoint(latLon, false, null);
}
}

View file

@ -174,9 +174,7 @@ public class RoutingHelper {
}
public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List<LatLon> intermediatePoints, Location currentLocation){
if (currentLocation != null) {
checkAndUpdateStartLocation(currentLocation);
}
checkAndUpdateStartLocation(currentLocation);
RouteCalculationResult previousRoute = route;
clearCurrentRoute(finalLocation, intermediatePoints);
// to update route
@ -268,10 +266,12 @@ public class RoutingHelper {
}
public void checkAndUpdateStartLocation(LatLon newStartLocation) {
LatLon lastStartLocation = app.getSettings().getLastStartPoint();
if (lastStartLocation == null || MapUtils.getDistance(newStartLocation, lastStartLocation) > CACHE_RADIUS) {
app.getMapViewTrackingUtilities().detectDrivingRegion(newStartLocation);
app.getSettings().setLastStartPoint(newStartLocation);
if (newStartLocation != null) {
LatLon lastStartLocation = app.getSettings().getLastStartPoint();
if (lastStartLocation == null || MapUtils.getDistance(newStartLocation, lastStartLocation) > CACHE_RADIUS) {
app.getMapViewTrackingUtilities().detectDrivingRegion(newStartLocation);
app.getSettings().setLastStartPoint(newStartLocation);
}
}
}