use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter in project Osmand by osmandapp.
the class MapRouteInfoMenu method updateStartPointView.
private void updateStartPointView() {
MapActivity mapActivity = getMapActivity();
final View mainView = getMainView();
if (mapActivity == null || mainView == null) {
return;
}
setupFromText(mainView);
View fromLayout = mainView.findViewById(R.id.FromLayout);
fromLayout.setOnClickListener(v -> {
MapActivity mapActv = getMapActivity();
if (mapActv != null) {
AddPointBottomSheetDialog.showInstance(mapActv, PointType.START);
}
});
FrameLayout fromButton = mainView.findViewById(R.id.from_button);
boolean isFollowTrack = mapActivity.getMyApplication().getRoutingHelper().getCurrentGPXRoute() != null;
if (isFollowTrack) {
fromButton.setVisibility(View.GONE);
} else {
fromButton.setVisibility(View.VISIBLE);
}
LinearLayout fromButtonContainer = mainView.findViewById(R.id.from_button_container);
setupButtonBackground(fromButton, fromButtonContainer);
ImageView swapDirectionView = mainView.findViewById(R.id.from_button_image_view);
setupButtonIcon(swapDirectionView, R.drawable.ic_action_change_navigation_points);
fromButton.setOnClickListener(view -> {
MapActivity mapActv = getMapActivity();
if (mapActv != null) {
OsmandApplication app = mapActv.getMyApplication();
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
TargetPoint startPoint = targetPointsHelper.getPointToStart();
TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
Location loc = app.getLocationProvider().getLastKnownLocation();
if (loc == null && startPoint == null && endPoint == null) {
app.showShortToastMessage(R.string.add_start_and_end_points);
} else if (endPoint == null) {
app.showShortToastMessage(R.string.mark_final_location_first);
} else {
GPXRouteParamsBuilder gpxParams = app.getRoutingHelper().getCurrentGPXRoute();
if (gpxParams != null) {
boolean reverse = !gpxParams.isReverse();
LocalRoutingParameter parameter = new OtherLocalRoutingParameter(R.string.gpx_option_reverse_route, app.getString(R.string.gpx_option_reverse_route), reverse);
app.getRoutingOptionsHelper().applyRoutingParameter(parameter, reverse);
} else {
if (startPoint == null && loc != null) {
startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()), new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION, mapActv.getString(R.string.shared_string_my_location)));
}
if (startPoint != null) {
int intermediateSize = targetPointsHelper.getIntermediatePoints().size();
if (intermediateSize > 1) {
WaypointDialogHelper.reverseAllPoints(app, mapActv, mapActv.getDashboard().getWaypointDialogHelper());
} else {
WaypointDialogHelper.switchStartAndFinish(mapActv.getMyApplication(), mapActv, mapActv.getDashboard().getWaypointDialogHelper(), true);
}
} else {
app.showShortToastMessage(R.string.route_add_start_point);
}
}
}
}
});
updateFromIcon(mainView);
final View textView = mainView.findViewById(R.id.from_button_description);
if (!swapButtonCollapsing && !swapButtonCollapsed && fromButton.getVisibility() == View.VISIBLE && textView.getVisibility() == View.VISIBLE) {
swapButtonCollapsing = true;
collapseButtonAnimated(R.id.from_button, R.id.from_button_description, success -> {
swapButtonCollapsing = false;
swapButtonCollapsed = success;
});
} else if (swapButtonCollapsed) {
textView.setVisibility(View.GONE);
}
}
use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter in project Osmand by osmandapp.
the class SelectedTrackToFollowCard method setupNavigateOptionsCard.
private void setupNavigateOptionsCard(ViewGroup cardsContainer, GPXRouteParamsBuilder routeParamsBuilder) {
int passRouteId = R.string.gpx_option_from_start_point;
LocalRoutingParameter passWholeRoute = new OtherLocalRoutingParameter(passRouteId, app.getString(passRouteId), routeParamsBuilder.isPassWholeRoute());
int navigationTypeId = R.string.gpx_option_calculate_first_last_segment;
LocalRoutingParameter navigationType = new OtherLocalRoutingParameter(navigationTypeId, app.getString(navigationTypeId), routeParamsBuilder.isCalculateOsmAndRouteParts());
int connectTrackPointsId = R.string.connect_track_points_as;
LocalRoutingParameter connectTrackPointStraightly = new OtherLocalRoutingParameter(connectTrackPointsId, app.getString(connectTrackPointsId), routeParamsBuilder.shouldConnectPointsStraightly());
NavigateTrackOptionsCard navigateTrackCard = new NavigateTrackOptionsCard(mapActivity, passWholeRoute, navigationType, connectTrackPointStraightly, routeParamsBuilder.useIntermediateRtePoints());
navigateTrackCard.setListener(target);
cardsContainer.addView(navigateTrackCard.build(mapActivity));
}
Aggregations