Merge pull request #4963 from osmandapp/PaulsBranch

Made start and intermediates draggable
This commit is contained in:
Alexander Sytnyk 2018-01-29 16:01:42 +02:00 committed by GitHub
commit 9806f189dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,24 @@ 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<TargetPoint> points = targetPointsHelper.getIntermediatePointsWithTarget();
int i = points.indexOf(oldPoint);
if (i != -1) {
newTargetPoint = new TargetPoint(position,
new PointDescription(PointDescription.POINT_TYPE_LOCATION, ""));
points.set(i, newTargetPoint);
targetPointsHelper.reorderAllTargetPoints(points, true);
}
}
result = true;
}
if (callback != null) {