Made start and intermediates draggable

This commit is contained in:
PaulStets 2018-01-29 15:13:34 +02:00
parent adb1b92c34
commit f859aee1a3

View file

@ -227,8 +227,12 @@ public class PointNavigationLayer extends OsmandMapLayer implements
@Override @Override
public boolean isObjectMovable(Object o) { public boolean isObjectMovable(Object o) {
TargetPointsHelper targetPoints = map.getMyApplication().getTargetPointsHelper(); TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper();
return o == targetPoints.getPointToNavigate(); if (o != null && o instanceof TargetPoint) {
TargetPoint tp = (TargetPoint) o;
return targetPointsHelper.getAllPoints().contains(tp);
}
return false;
} }
@Override @Override
@ -238,8 +242,20 @@ public class PointNavigationLayer extends OsmandMapLayer implements
TargetPoint newTargetPoint = null; TargetPoint newTargetPoint = null;
if (o instanceof TargetPoint) { if (o instanceof TargetPoint) {
TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper(); TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper();
targetPointsHelper.navigateToPoint(position, true, -1, new PointDescription(PointDescription.POINT_TYPE_LOCATION, "")); TargetPoint oldPoint = (TargetPoint) o;
newTargetPoint = targetPointsHelper.getPointToNavigate(); 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<TargetPoint> 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; result = true;
} }
if (callback != null) { if (callback != null) {