Search in sources :

Example 36 with TargetPointsHelper

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);
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) Paint(android.graphics.Paint)

Aggregations

TargetPointsHelper (net.osmand.plus.TargetPointsHelper)36 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)19 LatLon (net.osmand.data.LatLon)18 PointDescription (net.osmand.data.PointDescription)11 TextView (android.widget.TextView)8 OsmandApplication (net.osmand.plus.OsmandApplication)8 RoutingHelper (net.osmand.plus.routing.RoutingHelper)8 View (android.view.View)7 Location (net.osmand.Location)7 ImageView (android.widget.ImageView)5 DialogInterface (android.content.DialogInterface)4 AlertDialog (android.support.v7.app.AlertDialog)4 AdapterView (android.widget.AdapterView)4 ArrayList (java.util.ArrayList)4 ApplicationMode (net.osmand.plus.ApplicationMode)4 Paint (android.graphics.Paint)3 Bundle (android.os.Bundle)3 ImageButton (android.widget.ImageButton)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2