Skip to content

Commit

Permalink
Update MapProgressChangeListener to be aware of route visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
danesfeder committed Oct 30, 2018
1 parent f793097 commit 1bca8cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Expand Up @@ -11,6 +11,7 @@
class MapRouteProgressChangeListener implements ProgressChangeListener {

private final NavigationMapRoute mapRoute;
private boolean isVisible = true;

MapRouteProgressChangeListener(NavigationMapRoute mapRoute) {
this.mapRoute = mapRoute;
Expand All @@ -25,9 +26,13 @@ public void onProgressChange(Location location, RouteProgress routeProgress) {
mapRoute.addUpcomingManeuverArrow(routeProgress);
}

void updateVisibility(boolean isVisible) {
this.isVisible = isVisible;
}

private void addNewRoute(DirectionsRoute currentRoute, List<DirectionsRoute> directionsRoutes,
int primaryRouteIndex) {
if (isANewRoute(currentRoute, directionsRoutes, primaryRouteIndex)) {
if (isVisible && isANewRoute(currentRoute, directionsRoutes, primaryRouteIndex)) {
mapRoute.addRoute(currentRoute);
}
}
Expand Down
Expand Up @@ -172,7 +172,7 @@ public class NavigationMapRoute implements MapView.OnMapChangedListener,
private GeoJsonSource arrowHeadGeoJsonSource;
private Feature arrowShaftGeoJsonFeature = Feature.fromGeometry(Point.fromLngLat(0, 0));
private Feature arrowHeadGeoJsonFeature = Feature.fromGeometry(Point.fromLngLat(0, 0));
private ProgressChangeListener progressChangeListener = new MapRouteProgressChangeListener(this);
private MapRouteProgressChangeListener progressChangeListener = new MapRouteProgressChangeListener(this);

/**
* Construct an instance of {@link NavigationMapRoute}.
Expand Down Expand Up @@ -413,12 +413,14 @@ private void drawRoutes() {
addRouteShieldLayer(layerIds.get(layerIds.size() - 2), sourceId, index);
addRouteLayer(layerIds.get(layerIds.size() - 1), sourceId, index);
}
progressChangeListener.updateVisibility(true);
}

private void clearRoutes() {
removeLayerIds();
updateArrowLayersVisibilityTo(false);
clearRouteListData();
updateArrowLayersVisibilityTo(false);
progressChangeListener.updateVisibility(false);
}

private void generateFeatureCollectionList(List<DirectionsRoute> directionsRoutes) {
Expand Down

0 comments on commit 1bca8cb

Please sign in to comment.