From f859aee1a35b37326fad387f102ea04e1818a025 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Mon, 29 Jan 2018 15:13:34 +0200 Subject: [PATCH] Made start and intermediates draggable --- .../plus/views/PointNavigationLayer.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java index ad56fff866..6e0d1f9de2 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java @@ -227,8 +227,12 @@ public class PointNavigationLayer extends OsmandMapLayer implements @Override public boolean isObjectMovable(Object o) { - TargetPointsHelper targetPoints = map.getMyApplication().getTargetPointsHelper(); - return o == targetPoints.getPointToNavigate(); + TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper(); + if (o != null && o instanceof TargetPoint) { + TargetPoint tp = (TargetPoint) o; + return targetPointsHelper.getAllPoints().contains(tp); + } + return false; } @Override @@ -238,8 +242,20 @@ public class PointNavigationLayer extends OsmandMapLayer implements TargetPoint newTargetPoint = null; if (o instanceof TargetPoint) { TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper(); - targetPointsHelper.navigateToPoint(position, true, -1, new PointDescription(PointDescription.POINT_TYPE_LOCATION, "")); - newTargetPoint = targetPointsHelper.getPointToNavigate(); + TargetPoint oldPoint = (TargetPoint) o; + if (oldPoint.start) { + targetPointsHelper.setStartPoint(position, true, null); + newTargetPoint = targetPointsHelper.getPointToStart(); + } else if (oldPoint == targetPointsHelper.getPointToNavigate()) { + targetPointsHelper.navigateToPoint(position, true, -1, null); + newTargetPoint = targetPointsHelper.getPointToNavigate(); + } else if (oldPoint.intermediate) { + List points = targetPointsHelper.getIntermediatePointsWithTarget(); + newTargetPoint = new TargetPoint(position, + new PointDescription(PointDescription.POINT_TYPE_LOCATION, "")); + points.set(points.indexOf(oldPoint), newTargetPoint); + targetPointsHelper.reorderAllTargetPoints(points, true); + } result = true; } if (callback != null) {