Skip to content

Commit 1bca8cb

Browse files
committed
Update MapProgressChangeListener to be aware of route visibility
1 parent f793097 commit 1bca8cb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/route/MapRouteProgressChangeListener.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
class MapRouteProgressChangeListener implements ProgressChangeListener {
1212

1313
private final NavigationMapRoute mapRoute;
14+
private boolean isVisible = true;
1415

1516
MapRouteProgressChangeListener(NavigationMapRoute mapRoute) {
1617
this.mapRoute = mapRoute;
@@ -25,9 +26,13 @@ public void onProgressChange(Location location, RouteProgress routeProgress) {
2526
mapRoute.addUpcomingManeuverArrow(routeProgress);
2627
}
2728

29+
void updateVisibility(boolean isVisible) {
30+
this.isVisible = isVisible;
31+
}
32+
2833
private void addNewRoute(DirectionsRoute currentRoute, List<DirectionsRoute> directionsRoutes,
2934
int primaryRouteIndex) {
30-
if (isANewRoute(currentRoute, directionsRoutes, primaryRouteIndex)) {
35+
if (isVisible && isANewRoute(currentRoute, directionsRoutes, primaryRouteIndex)) {
3136
mapRoute.addRoute(currentRoute);
3237
}
3338
}

libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/route/NavigationMapRoute.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public class NavigationMapRoute implements MapView.OnMapChangedListener,
172172
private GeoJsonSource arrowHeadGeoJsonSource;
173173
private Feature arrowShaftGeoJsonFeature = Feature.fromGeometry(Point.fromLngLat(0, 0));
174174
private Feature arrowHeadGeoJsonFeature = Feature.fromGeometry(Point.fromLngLat(0, 0));
175-
private ProgressChangeListener progressChangeListener = new MapRouteProgressChangeListener(this);
175+
private MapRouteProgressChangeListener progressChangeListener = new MapRouteProgressChangeListener(this);
176176

177177
/**
178178
* Construct an instance of {@link NavigationMapRoute}.
@@ -413,12 +413,14 @@ private void drawRoutes() {
413413
addRouteShieldLayer(layerIds.get(layerIds.size() - 2), sourceId, index);
414414
addRouteLayer(layerIds.get(layerIds.size() - 1), sourceId, index);
415415
}
416+
progressChangeListener.updateVisibility(true);
416417
}
417418

418419
private void clearRoutes() {
419420
removeLayerIds();
420-
updateArrowLayersVisibilityTo(false);
421421
clearRouteListData();
422+
updateArrowLayersVisibilityTo(false);
423+
progressChangeListener.updateVisibility(false);
422424
}
423425

424426
private void generateFeatureCollectionList(List<DirectionsRoute> directionsRoutes) {

0 commit comments

Comments
 (0)