Search in sources :

Example 16 with RoutingHelper

use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.

the class MarkersPlanRouteContext method scheduleRouteCalculateIfNotEmpty.

private void scheduleRouteCalculateIfNotEmpty(List<WptPt> points) {
    if (points.isEmpty()) {
        return;
    }
    findPairsToCalculate(points);
    RoutingHelper routingHelper = app.getRoutingHelper();
    if (!snapToRoadPairsToCalculate.isEmpty() && !routingHelper.isRouteBeingCalculated()) {
        routingHelper.startRouteCalculationThread(getParams(), true, true);
        app.runInUIThread(new Runnable() {

            @Override
            public void run() {
                listener.showProgressBar();
            }
        });
    }
}
Also used : RoutingHelper(net.osmand.plus.routing.RoutingHelper)

Example 17 with RoutingHelper

use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.

the class AvoidSpecificRoads method addImpassableRoadInternal.

private void addImpassableRoadInternal(@NonNull RouteDataObject object, @NonNull Location ll, boolean showDialog, @Nullable MapActivity activity, @NonNull LatLon loc) {
    if (!app.getDefaultRoutingConfig().addImpassableRoad(object, ll)) {
        LatLon location = getLocation(object);
        if (location != null) {
            app.getSettings().removeImpassableRoad(getLocation(object));
        }
    }
    RoutingHelper rh = app.getRoutingHelper();
    if (rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
        rh.recalculateRouteDueToSettingsChange();
    }
    if (activity != null) {
        if (showDialog) {
            showDialog(activity);
        }
        MapContextMenu menu = activity.getContextMenu();
        if (menu.isActive() && menu.getLatLon().equals(loc)) {
            menu.close();
        }
        activity.refreshMap();
    }
}
Also used : LatLon(net.osmand.data.LatLon) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu) RoutingHelper(net.osmand.plus.routing.RoutingHelper)

Example 18 with RoutingHelper

use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.

the class AvoidSpecificRoads method createAdapter.

private ArrayAdapter<RouteDataObject> createAdapter(final MapActivity ctx) {
    final ArrayList<RouteDataObject> points = new ArrayList<>();
    points.addAll(getImpassableRoads());
    final LatLon mapLocation = ctx.getMapLocation();
    return new ArrayAdapter<RouteDataObject>(ctx, R.layout.waypoint_reached, R.id.title, points) {

        @NonNull
        @Override
        public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
            View v = convertView;
            if (v == null || v.findViewById(R.id.info_close) == null) {
                v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, parent, false);
            }
            final RouteDataObject obj = getItem(position);
            v.findViewById(R.id.all_points).setVisibility(View.GONE);
            ((ImageView) v.findViewById(R.id.waypoint_icon)).setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_road_works_dark));
            double dist = MapUtils.getDistance(mapLocation, MapUtils.get31LatitudeY(obj.getPoint31YTile(0)), MapUtils.get31LongitudeX(obj.getPoint31XTile(0)));
            ((TextView) v.findViewById(R.id.waypoint_dist)).setText(OsmAndFormatter.getFormattedDistance((float) dist, app));
            ((TextView) v.findViewById(R.id.waypoint_text)).setText(getText(obj));
            ImageButton remove = (ImageButton) v.findViewById(R.id.info_close);
            remove.setVisibility(View.VISIBLE);
            remove.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark));
            remove.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    remove(obj);
                    removeImpassableRoad(obj);
                    notifyDataSetChanged();
                    RoutingHelper rh = app.getRoutingHelper();
                    if (rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
                        rh.recalculateRouteDueToSettingsChange();
                    }
                }
            });
            return v;
        }
    };
}
Also used : ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) RoutingHelper(net.osmand.plus.routing.RoutingHelper) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LatLon(net.osmand.data.LatLon) ImageButton(android.widget.ImageButton) NonNull(android.support.annotation.NonNull) RouteDataObject(net.osmand.binary.RouteDataObject) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ArrayAdapter(android.widget.ArrayAdapter)

Example 19 with RoutingHelper

use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.

the class DashNavigationFragment method setupNavigation.

public void setupNavigation() {
    View mainView = getView();
    final RoutingHelper routingHelper = getMyApplication().getRoutingHelper();
    getActivity();
    if (!routingHelper.isRouteCalculated() || (!(getActivity() instanceof MapActivity))) {
        (mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
        return;
    } else {
        (mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
    }
    final MapActivity map = (MapActivity) getActivity();
    LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
    favorites.removeAllViews();
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.dash_navigation, null, false);
    TextView name = (TextView) view.findViewById(R.id.name);
    ImageView icon = (ImageView) view.findViewById(R.id.icon);
    ImageView cancel = (ImageView) view.findViewById(R.id.cancel);
    ImageView play = (ImageView) view.findViewById(R.id.play);
    name.setText(routingHelper.getGeneralRouteInformation());
    icon.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance));
    cancel.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark));
    cancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog dlg = map.getMapActions().stopNavigationActionConfirm();
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {

                @Override
                public void onDismiss(DialogInterface dialog) {
                    setupNavigation();
                    DashWaypointsFragment f = dashboard.getFragmentByClass(DashWaypointsFragment.class);
                    if (f != null) {
                        f.onOpenDash();
                    }
                }
            });
        }
    });
    int nav;
    if (routingHelper.isFollowingMode()) {
        nav = R.string.cancel_navigation;
    } else {
        nav = R.string.cancel_route;
    }
    cancel.setContentDescription(getString(nav));
    updatePlayButton(routingHelper, map, play);
    favorites.addView(view);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) RoutingHelper(net.osmand.plus.routing.RoutingHelper) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) MapActivity(net.osmand.plus.activities.MapActivity)

Example 20 with RoutingHelper

use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.

the class DashboardOnMap method isInRouteOrPlannigMode.

private boolean isInRouteOrPlannigMode() {
    boolean routePlanningMode = false;
    RoutingHelper rh = mapActivity.getRoutingHelper();
    if (rh.isRoutePlanningMode()) {
        routePlanningMode = true;
    } else if ((rh.isRouteCalculated() || rh.isRouteBeingCalculated()) && !rh.isFollowingMode()) {
        routePlanningMode = true;
    }
    boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
    return routePlanningMode || routeFollowingMode;
}
Also used : RoutingHelper(net.osmand.plus.routing.RoutingHelper)

Aggregations

RoutingHelper (net.osmand.plus.routing.RoutingHelper)38 LatLon (net.osmand.data.LatLon)9 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)9 OsmandApplication (net.osmand.plus.OsmandApplication)8 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)8 PointDescription (net.osmand.data.PointDescription)7 Intent (android.content.Intent)6 DialogInterface (android.content.DialogInterface)5 AlertDialog (android.support.v7.app.AlertDialog)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 Paint (android.graphics.Paint)4 NextDirectionInfo (net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo)4 TurnType (net.osmand.router.TurnType)4 PendingIntent (android.app.PendingIntent)3 BroadcastReceiver (android.content.BroadcastReceiver)3 Context (android.content.Context)3 IntentFilter (android.content.IntentFilter)3 Uri (android.net.Uri)3