Fix removeWayPoint crash

This commit is contained in:
max-klaus 2019-10-13 10:47:17 +03:00
parent 5342d4a0e2
commit a262a13fbf

View file

@ -496,12 +496,12 @@ public class TargetPointsHelper {
updateRouteAndRefresh(updateRoute); updateRouteAndRefresh(updateRoute);
} }
public void removeWayPoint(boolean updateRoute, int index){ public void removeWayPoint(boolean updateRoute, int index) {
int sz = intermediatePoints.size();
if (index < 0) { if (index < 0) {
cancelTargetPointAddressRequest(); cancelTargetPointAddressRequest();
settings.clearPointToNavigate(); settings.clearPointToNavigate();
pointToNavigate = null; pointToNavigate = null;
int sz = intermediatePoints.size();
if (sz > 0) { if (sz > 0) {
settings.deleteIntermediatePoint(sz - 1); settings.deleteIntermediatePoint(sz - 1);
pointToNavigate = intermediatePoints.remove(sz - 1); pointToNavigate = intermediatePoints.remove(sz - 1);
@ -510,7 +510,7 @@ public class TargetPointsHelper {
pointToNavigate.pointDescription); pointToNavigate.pointDescription);
lookupAddressForPointToNavigate(); lookupAddressForPointToNavigate();
} }
} else { } else if (sz > index) {
settings.deleteIntermediatePoint(index); settings.deleteIntermediatePoint(index);
TargetPoint targetPoint = intermediatePoints.remove(index); TargetPoint targetPoint = intermediatePoints.remove(index);
cancelPointAddressRequests(targetPoint.point); cancelPointAddressRequests(targetPoint.point);