From c999ffd542bd81e9e19977626608d829d7120e5c Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 26 Jan 2018 15:14:23 +0200 Subject: [PATCH] Fix waypoints swapping and deleting --- .../osmand/plus/dashboard/DashboardOnMap.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index c005c66ac5..9eca8830e8 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -1487,13 +1487,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis public void run() { if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) { List allTargets = new ArrayList<>(); + TargetPoint start = null; if (items != null) { for (Object obj : items) { if (obj instanceof LocationPointWrapper) { LocationPointWrapper p = (LocationPointWrapper) obj; if (p.getPoint() instanceof TargetPoint) { TargetPoint t = (TargetPoint) p.getPoint(); - t.intermediate = true; + if (t.start) { + start = t; + } else { + t.intermediate = true; + } allTargets.add(t); } } @@ -1503,15 +1508,24 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } } TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper(); - if (allTargets.size() > 0) { - TargetPoint start = allTargets.remove(0); - targetPointsHelper.setStartPoint(new LatLon(start.getLatitude(), start.getLongitude()), - false, start.getPointDescription(getMyApplication())); + if (start != null) { + int startInd = allTargets.indexOf(start); + TargetPoint first = allTargets.remove(0); + if (startInd != 0) { + start.start = false; + start.intermediate = startInd != allTargets.size() - 1; + if (targetPointsHelper.getPointToStart() == null) { + start.getOriginalPointDescription().setName(start.getLatitude() + ", " + start.getLongitude()); + } + first.start = true; + first.intermediate = false; + targetPointsHelper.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()), + false, first.getPointDescription(getMyApplication())); + } } targetPointsHelper.reorderAllTargetPoints(allTargets, false); newRouteIsCalculated(false, new ValueHolder()); targetPointsHelper.updateRouteAndRefresh(true); - } } }, 50);