From c941880444c42ed55e5a47060a0b8b3cb37ed250 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 17 Feb 2021 15:02:26 +0200 Subject: [PATCH] Fix reverse for multisegment --- .../FollowTrackFragment.java | 24 +++++++++---------- .../osmand/plus/routing/RouteProvider.java | 6 ++++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 82a8ea2d88..dc2d1ec79e 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -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); } diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 051a5218fa..eb1ffedae5 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -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);