Fix waypoints swapping and deleting
This commit is contained in:
parent
95f1f77e9c
commit
c999ffd542
1 changed files with 20 additions and 6 deletions
|
@ -1487,13 +1487,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
public void run() {
|
||||
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
|
||||
List<TargetPoint> 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();
|
||||
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<Boolean>());
|
||||
targetPointsHelper.updateRouteAndRefresh(true);
|
||||
|
||||
}
|
||||
}
|
||||
}, 50);
|
||||
|
|
Loading…
Reference in a new issue