Merge pull request #413 from michc/fix_waypoint_editor_bug
Fix for bug that throws array out of bounds error when editing the waypo...
This commit is contained in:
commit
aec1e29da6
1 changed files with 15 additions and 8 deletions
|
@ -156,11 +156,17 @@ public class IntermediatePointsDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cnt > 0) {
|
if (cnt > 0) {
|
||||||
for (int i = checkedIntermediates.length - 1; i >= 0; i--) {
|
boolean changeDestinationFlag =!checkedIntermediates [checkedIntermediates.length - 1];
|
||||||
if (!checkedIntermediates[i]) {
|
if(cnt == checkedIntermediates.length){ //there is no alternative destination if all points are to be removed?
|
||||||
|
app.getTargetPointsHelper().removeAllWayPoints((MapActivity) (mapActivity instanceof MapActivity?mapActivity : null), true);
|
||||||
|
}else{
|
||||||
|
for (int i = checkedIntermediates.length - 2; i >= 0; i--) { //skip the destination until a retained waypoint is found
|
||||||
|
if (checkedIntermediates[i] && changeDestinationFlag) { //Find a valid replacement for the destination
|
||||||
|
app.getTargetPointsHelper().makeWayPointDestination((MapActivity) (mapActivity instanceof MapActivity?mapActivity : null), cnt == 0, i);
|
||||||
|
changeDestinationFlag = false;
|
||||||
|
}else if(!checkedIntermediates[i]){
|
||||||
cnt--;
|
cnt--;
|
||||||
app.getTargetPointsHelper().removeWayPoint((MapActivity) (mapActivity instanceof MapActivity?mapActivity : null), cnt == 0,
|
app.getTargetPointsHelper().removeWayPoint((MapActivity) (mapActivity instanceof MapActivity?mapActivity : null), cnt == 0, i);
|
||||||
i == checkedIntermediates.length - 1? -1 : i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(mapActivity instanceof MapActivity) {
|
if(mapActivity instanceof MapActivity) {
|
||||||
|
@ -168,6 +174,7 @@ public class IntermediatePointsDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void commitChangePointsOrder(OsmandApplication app, final Activity mapActivity, List<LatLon> target, List<String> names) {
|
private static void commitChangePointsOrder(OsmandApplication app, final Activity mapActivity, List<LatLon> target, List<String> names) {
|
||||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||||
|
|
Loading…
Reference in a new issue