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();
}
});
}
}
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();
}
}
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;
}
};
}
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);
}
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;
}
Aggregations