Add filter for nearby routes badges

This commit is contained in:
Chumva 2018-10-18 16:39:13 +03:00
parent 2b3ab31b10
commit fdd52c087c

View file

@ -688,6 +688,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
return filteredRoutes;
}
private List<TransportStopRoute> filterNearbyTransportRoutes(List<TransportStopRoute> routes, List<TransportStopRoute> filterFromRoutes) {
List<TransportStopRoute> filteredRoutes = new ArrayList<>();
for (TransportStopRoute route : routes) {
if (!containsRef(filterFromRoutes, route.route)) {
filteredRoutes.add(route);
}
}
return filteredRoutes;
}
private boolean containsRef(List<TransportStopRoute> routes, TransportRoute transportRoute) {
for (TransportStopRoute route : routes) {
if (route.route.getRef().equals(transportRoute.getRef())) {
@ -1297,7 +1307,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
updateLocalRoutesBadges(localFilteredTransportStopRoutes, localColumnsPerRow);
}
if (nearbyTransportStopRoutes != null) {
updateNearbyRoutesBadges(maxLocalRows, filterTransportRoutes(nearbyTransportStopRoutes));
updateNearbyRoutesBadges(maxLocalRows, filterNearbyTransportRoutes(nearbyTransportStopRoutes, localTransportStopRoutes));
}
transportBadgesCreated = true;
}