diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-02-15 16:42:56 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-02-15 16:42:56 +0000 |
commit | dd82262b990a609c715ee43386d149416d1fefbf (patch) | |
tree | 92113c1c61371f1f1ee6d4c100d8ff040ec92d1b /src/net/cbaines/suma/Timetable.java | |
parent | 663b57be020d4e6ef1cc7eaa9f5fca5ad7846653 (diff) | |
download | southamptonuniversitymap-dd82262b990a609c715ee43386d149416d1fefbf.tar southamptonuniversitymap-dd82262b990a609c715ee43386d149416d1fefbf.tar.gz |
Working stop bus arival prediction.
Diffstat (limited to 'src/net/cbaines/suma/Timetable.java')
-rw-r--r-- | src/net/cbaines/suma/Timetable.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/net/cbaines/suma/Timetable.java b/src/net/cbaines/suma/Timetable.java index 6e3db1e..93c8e8d 100644 --- a/src/net/cbaines/suma/Timetable.java +++ b/src/net/cbaines/suma/Timetable.java @@ -28,7 +28,7 @@ public class Timetable extends ArrayList<Stop> { * */ private static final long serialVersionUID = -9021303378059511643L; - + Date fetchTime; public String toString() { @@ -40,6 +40,8 @@ public class Timetable extends ArrayList<Stop> { } public boolean contains(Stop otherStop, boolean toTheMinute) { + if (otherStop == null) + return false; if (toTheMinute) { for (Stop stop : this) { if (otherStop.bus != null && stop.bus != null && otherStop.bus.equals(stop.bus)) { @@ -47,8 +49,14 @@ public class Timetable extends ArrayList<Stop> { return true; } } else if (otherStop.busStop.equals(stop.busStop)) { - if (Math.abs(otherStop.arivalTime.getTime() - stop.arivalTime.getTime()) < 60000) { + if (otherStop.arivalTime == null && stop.arivalTime == null) { return true; + } else { + if (otherStop.arivalTime == null || stop.arivalTime == null) { + return false; + } else if (Math.abs(otherStop.arivalTime.getTime() - stop.arivalTime.getTime()) < 60000) { + return true; + } } } } |