From 2481142f0b01bd7220bcb09651206e43aba06e06 Mon Sep 17 00:00:00 2001 From: MadWasp79 Date: Wed, 29 Jan 2020 11:25:05 +0200 Subject: [PATCH] add npe checks --- OsmAnd/src/net/osmand/plus/TargetPointsHelper.java | 4 +--- .../src/net/osmand/plus/routing/RoutingHelper.java | 14 +++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java index 005e38d71e..046456a172 100644 --- a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java @@ -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); } } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 75ca6d2dd0..11c0d56d9e 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -174,9 +174,7 @@ public class RoutingHelper { } public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List 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); + } } }