Do not add duplicates

This commit is contained in:
PavelRatushny 2017-12-15 10:33:31 +02:00
parent bb62e054e8
commit 14dc6f90cf
2 changed files with 38 additions and 16 deletions

View file

@ -227,6 +227,7 @@ public class AmenityMenuController extends MenuController {
Collection<TransportRoute> rts = t.getRouteForStop(s);
if (rts != null) {
for (TransportRoute rs : rts) {
if (!containsRef(rs)) {
TransportStopController.TransportStopType type = TransportStopController.TransportStopType.findType(rs.getType());
TransportStopRoute r = new TransportStopRoute();
r.type = type;
@ -239,3 +240,13 @@ public class AmenityMenuController extends MenuController {
}
}
}
private boolean containsRef(TransportRoute transportRoute) {
for (TransportStopRoute route : routes) {
if (route.route.getRef().equals(transportRoute.getRef())) {
return true;
}
}
return false;
}
}

View file

@ -201,10 +201,11 @@ public class TransportStopController extends MenuController {
if (rts != null) {
for (TransportRoute rs : rts) {
TransportStopType type = TransportStopType.findType(rs.getType());
TransportStopRoute r = new TransportStopRoute();
if (topType == null && type != null && type.isTopType()) {
topType = type;
}
if (!containsRef(rs)) {
TransportStopRoute r = new TransportStopRoute();
r.type = type;
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
r.route = rs;
@ -215,6 +216,16 @@ public class TransportStopController extends MenuController {
}
}
}
}
private boolean containsRef(TransportRoute transportRoute) {
for (TransportStopRoute route : routes) {
if (route.route.getRef().equals(transportRoute.getRef())) {
return true;
}
}
return false;
}
public static class TransportStopRoute {
public TransportStop refStop;