Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@
class MapRouteProgressChangeListener implements ProgressChangeListener {

private final NavigationMapRoute mapRoute;
private boolean isVisible = true;

MapRouteProgressChangeListener(NavigationMapRoute mapRoute) {
this.mapRoute = mapRoute;
}

@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
if (!isVisible) {
return;
}
DirectionsRoute currentRoute = routeProgress.directionsRoute();
List<DirectionsRoute> directionsRoutes = mapRoute.retrieveDirectionsRoutes();
int primaryRouteIndex = mapRoute.retrievePrimaryRouteIndex();
addNewRoute(currentRoute, directionsRoutes, primaryRouteIndex);
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)) {
Expand Down
Original file line number Diff line number Diff line change
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