From 1e10c632ebc0e90b8489bcf856534877a4c8cbef Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 26 Jul 2023 13:08:58 +0300 Subject: [PATCH] Fix IndexOutOfBoundsException --- .../plus/measurementtool/MeasurementEditingContext.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java index defa934878d..a16add0cc8a 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java @@ -1079,9 +1079,12 @@ public List setPoints(GpxRouteApproximation gpxApproximation, List return routePoints; } - private boolean needDuplicatePoint(List gpxPoints, int i) { - List routeToTarget = gpxPoints.get(i).routeToTarget; - List routeToTargetNext = gpxPoints.get(i + 1).routeToTarget; + private boolean needDuplicatePoint(List gpxPoints, int index) { + if (index == gpxPoints.size() - 1) { + return false; + } + List routeToTarget = gpxPoints.get(index).routeToTarget; + List routeToTargetNext = gpxPoints.get(index + 1).routeToTarget; return routeToTarget.get(routeToTarget.size() - 1).getEndPoint() .equals(routeToTargetNext.get(0).getStartPoint()); }