From a873801249d166534107c272d08a92d536133948 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 21 Dec 2018 17:40:27 +0100 Subject: [PATCH] Trip: Mark trip as untravelable if important departures or arrivals are cancelled. --- enabler/src/de/schildbach/pte/dto/Trip.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/enabler/src/de/schildbach/pte/dto/Trip.java b/enabler/src/de/schildbach/pte/dto/Trip.java index 5c86a02a..492efa6b 100644 --- a/enabler/src/de/schildbach/pte/dto/Trip.java +++ b/enabler/src/de/schildbach/pte/dto/Trip.java @@ -187,11 +187,20 @@ public final class Trip implements Serializable { } } - /** Returns true if no legs overlap, false otherwise. */ + /** + * Returns true if it looks like the trip can be traveled. Returns false if legs overlap, important + * departures or arrivals are cancelled and that sort of thing. + */ public boolean isTravelable() { Date time = null; for (final Leg leg : legs) { + if (leg instanceof Public) { + final Public publicLeg = (Public) leg; + if (publicLeg.departureStop.departureCancelled || publicLeg.arrivalStop.arrivalCancelled) + return false; + } + final Date departureTime = leg.getDepartureTime(); if (time != null && departureTime.before(time)) return false;