use of net.osmand.plus.TargetPointsHelper in project Osmand by osmandapp.
the class PointNavigationLayer method applyNewObjectPosition.
@Override
public void applyNewObjectPosition(@NonNull Object o, @NonNull LatLon position, @Nullable ContextMenuLayer.ApplyMovedObjectCallback callback) {
boolean result = false;
TargetPoint newTargetPoint = null;
if (o instanceof TargetPoint) {
TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper();
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) {
callback.onApplyMovedObject(result, newTargetPoint == null ? o : newTargetPoint);
}
}
Aggregations