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

View file

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