Fix reverse for multisegment

This commit is contained in:
Vitaliy 2021-02-17 15:02:26 +02:00
parent e4b902c6f4
commit c941880444
2 changed files with 16 additions and 14 deletions

View file

@ -226,16 +226,14 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
GPXRouteParamsBuilder rparams = routingHelper.getCurrentGPXRoute();
boolean osmandRouter = mode.getRouteService() == RouteProvider.RouteService.OSMAND;
if (rparams != null && osmandRouter) {
boolean showReverseCard = !routingHelper.isCurrentGPXRouteV2();
if (showReverseCard) {
cardsContainer.addView(buildDividerView(cardsContainer, false));
cardsContainer.addView(buildDividerView(cardsContainer, false));
ReverseTrackCard reverseTrackCard = new ReverseTrackCard(mapActivity, rparams.isReverse());
reverseTrackCard.setListener(this);
cardsContainer.addView(reverseTrackCard.build(mapActivity));
ReverseTrackCard reverseTrackCard = new ReverseTrackCard(mapActivity, rparams.isReverse());
reverseTrackCard.setListener(this);
cardsContainer.addView(reverseTrackCard.build(mapActivity));
}
if (!gpxFile.hasRtePt() && !gpxFile.hasRoute()) {
cardsContainer.addView(buildDividerView(cardsContainer, showReverseCard));
cardsContainer.addView(buildDividerView(cardsContainer, true));
AttachTrackToRoadsCard attachTrackCard = new AttachTrackToRoadsCard(mapActivity);
attachTrackCard.setListener(this);
@ -721,11 +719,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
@Override
public void onSegmentSelect(GPXFile gpxFile, int selectedSegment) {
selectTrackToFollow(gpxFile);
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (paramsBuilder != null) {
paramsBuilder.setSelectedSegment(selectedSegment);
app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
app.getRoutingHelper().onSettingsChanged(true);
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (paramsBuilder != null) {
paramsBuilder.setSelectedSegment(selectedSegment);
app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
app.getRoutingHelper().onSettingsChanged(true);
}
updateSelectionMode(false);
}

View file

@ -289,7 +289,11 @@ public class RouteProvider {
int selectedSegment = builder.getSelectedSegment();
if (OSMAND_ROUTER_V2.equals(file.author)) {
route = parseOsmAndGPXRoute(points, file, selectedSegment);
routePoints = file.getRoutePoints();
if (selectedSegment == -1) {
routePoints = file.getRoutePoints();
} else {
routePoints = file.getRoutePoints(selectedSegment);
}
if (reverse) {
Collections.reverse(points);
Collections.reverse(routePoints);