From d9499a3329bdac28ee791b910b9b303b02aa8618 Mon Sep 17 00:00:00 2001 From: "andreas.schildbach" Date: Sun, 5 Sep 2010 12:51:17 +0000 Subject: [PATCH] make footway arrival clickable git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@131 0924bc21-9374-b0fa-ee44-9ff1593b38f0 --- src/de/schildbach/pte/BahnProvider.java | 6 +++--- src/de/schildbach/pte/Connection.java | 15 +++++++-------- src/de/schildbach/pte/MvvProvider.java | 4 ++-- src/de/schildbach/pte/OebbProvider.java | 12 +++++++++--- src/de/schildbach/pte/RmvProvider.java | 4 ++-- src/de/schildbach/pte/SbbProvider.java | 12 +++++++++--- src/de/schildbach/pte/VbbProvider.java | 5 +++-- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/de/schildbach/pte/BahnProvider.java b/src/de/schildbach/pte/BahnProvider.java index 617c83cd..a572d1b4 100644 --- a/src/de/schildbach/pte/BahnProvider.java +++ b/src/de/schildbach/pte/BahnProvider.java @@ -388,11 +388,11 @@ public final class BahnProvider implements NetworkProvider if (parts.size() > 0 && parts.get(parts.size() - 1) instanceof Connection.Footway) { final Connection.Footway lastFootway = (Connection.Footway) parts.remove(parts.size() - 1); - parts.add(new Connection.Footway(lastFootway.min + Integer.parseInt(min), lastFootway.departure, arrival)); + parts.add(new Connection.Footway(lastFootway.min + Integer.parseInt(min), 0, lastFootway.departure, 0, arrival)); } else { - parts.add(new Connection.Footway(Integer.parseInt(min), departure, arrival)); + parts.add(new Connection.Footway(Integer.parseInt(min), 0, departure, 0, arrival)); } lastArrival = arrival; @@ -401,7 +401,7 @@ public final class BahnProvider implements NetworkProvider { final String arrival = ParserUtils.resolveEntities(mDetFine.group(12)); - parts.add(new Connection.Footway(0, departure, arrival)); + parts.add(new Connection.Footway(0, 0, departure, 0, arrival)); } } else diff --git a/src/de/schildbach/pte/Connection.java b/src/de/schildbach/pte/Connection.java index f8091977..803f7cca 100644 --- a/src/de/schildbach/pte/Connection.java +++ b/src/de/schildbach/pte/Connection.java @@ -118,11 +118,6 @@ public final class Connection implements Serializable this.arrival = arrival; } - public Trip(final Date departureTime, final Date arrivalTime, final String line, final int[] lineColors) - { - this(line, lineColors, null, departureTime, null, 0, null, arrivalTime, null, 0, null); - } - @Override public String toString() { @@ -144,13 +139,17 @@ public final class Connection implements Serializable public final static class Footway implements Part { final public int min; + final public int departureId; final public String departure; + final public int arrivalId; final public String arrival; - public Footway(final int min, final String departure, final String arrival) + public Footway(final int min, final int departureId, final String departure, final int arrivalId, final String arrival) { this.min = min; + this.departureId = departureId; this.departure = departure; + this.arrivalId = arrivalId; this.arrival = arrival; } @@ -160,9 +159,9 @@ public final class Connection implements Serializable final StringBuilder builder = new StringBuilder(getClass().getName() + "["); builder.append("min=").append(min); builder.append(","); - builder.append("departure=").append(departure); + builder.append("departure=").append(departureId).append("/").append(departure); builder.append(","); - builder.append("arrival=").append(arrival); + builder.append("arrival=").append(arrivalId).append("/").append(arrival); builder.append("]"); return builder.toString(); } diff --git a/src/de/schildbach/pte/MvvProvider.java b/src/de/schildbach/pte/MvvProvider.java index ae97d669..ff678fc9 100644 --- a/src/de/schildbach/pte/MvvProvider.java +++ b/src/de/schildbach/pte/MvvProvider.java @@ -536,11 +536,11 @@ public class MvvProvider implements NetworkProvider if (parts.size() > 0 && parts.get(parts.size() - 1) instanceof Connection.Footway) { final Connection.Footway lastFootway = (Connection.Footway) parts.remove(parts.size() - 1); - parts.add(new Connection.Footway(lastFootway.min + Integer.parseInt(min), lastFootway.departure, arrival)); + parts.add(new Connection.Footway(lastFootway.min + Integer.parseInt(min), 0, lastFootway.departure, 0, arrival)); } else { - parts.add(new Connection.Footway(Integer.parseInt(min), departure, arrival)); + parts.add(new Connection.Footway(Integer.parseInt(min), 0, departure, 0, arrival)); } lastArrival = arrival; diff --git a/src/de/schildbach/pte/OebbProvider.java b/src/de/schildbach/pte/OebbProvider.java index 56bf5e00..81c813e8 100644 --- a/src/de/schildbach/pte/OebbProvider.java +++ b/src/de/schildbach/pte/OebbProvider.java @@ -288,6 +288,8 @@ public class OebbProvider implements NetworkProvider final Matcher mDetFine = P_CONNECTION_DETAILS_FINE.matcher(set); if (mDetFine.matches()) { + final int departureId = mDetFine.group(1) != null ? Integer.parseInt(mDetFine.group(1)) : 0; + final String departure = ParserUtils.resolveEntities(mDetFine.group(2)); Date departureDate = mDetFine.group(3) != null ? ParserUtils.parseDate(mDetFine.group(3)) : null; @@ -298,6 +300,8 @@ public class OebbProvider implements NetworkProvider final String lineType = mDetFine.group(6); + final int arrivalId = mDetFine.group(8) != null ? Integer.parseInt(mDetFine.group(8)) : 0; + final String arrival = ParserUtils.resolveEntities(mDetFine.group(9)); Date arrivalDate = mDetFine.group(10) != null ? ParserUtils.parseDate(mDetFine.group(10)) : null; @@ -308,7 +312,8 @@ public class OebbProvider implements NetworkProvider if (!lineType.equals("fuss")) { - final int departureId = Integer.parseInt(mDetFine.group(1)); + if (departureId == 0) + throw new IllegalStateException("departureId"); final Date departureTime = ParserUtils.joinDateTime(departureDate, ParserUtils.parseTime(mDetFine.group(4))); @@ -316,7 +321,8 @@ public class OebbProvider implements NetworkProvider final String line = normalizeLine(lineType, ParserUtils.resolveEntities(mDetFine.group(7))); - final int arrivalId = Integer.parseInt(mDetFine.group(8)); + if (arrivalId == 0) + throw new IllegalStateException("arrivalId"); final Date arrivalTime = ParserUtils.joinDateTime(arrivalDate, ParserUtils.parseTime(mDetFine.group(11))); @@ -330,7 +336,7 @@ public class OebbProvider implements NetworkProvider { final int min = Integer.parseInt(mDetFine.group(13)); - final Connection.Footway footway = new Connection.Footway(min, departure, arrival); + final Connection.Footway footway = new Connection.Footway(min, departureId, departure, arrivalId, arrival); connection.parts.add(footway); } } diff --git a/src/de/schildbach/pte/RmvProvider.java b/src/de/schildbach/pte/RmvProvider.java index 0fd62a98..dc95fa00 100644 --- a/src/de/schildbach/pte/RmvProvider.java +++ b/src/de/schildbach/pte/RmvProvider.java @@ -387,11 +387,11 @@ public class RmvProvider implements NetworkProvider if (parts.size() > 0 && parts.get(parts.size() - 1) instanceof Connection.Footway) { final Connection.Footway lastFootway = (Connection.Footway) parts.remove(parts.size() - 1); - parts.add(new Connection.Footway(lastFootway.min + Integer.parseInt(min), lastFootway.departure, arrival)); + parts.add(new Connection.Footway(lastFootway.min + Integer.parseInt(min), 0, lastFootway.departure, 0, arrival)); } else { - parts.add(new Connection.Footway(Integer.parseInt(min), departure, arrival)); + parts.add(new Connection.Footway(Integer.parseInt(min), 0, departure, 0, arrival)); } } } diff --git a/src/de/schildbach/pte/SbbProvider.java b/src/de/schildbach/pte/SbbProvider.java index 2dcfadff..58d7f5bf 100644 --- a/src/de/schildbach/pte/SbbProvider.java +++ b/src/de/schildbach/pte/SbbProvider.java @@ -288,6 +288,8 @@ public class SbbProvider implements NetworkProvider final Matcher mDetFine = P_CONNECTION_DETAILS_FINE.matcher(set); if (mDetFine.matches()) { + final int departureId = mDetFine.group(1) != null ? Integer.parseInt(mDetFine.group(1)) : 0; + final String departure = ParserUtils.resolveEntities(mDetFine.group(2)); Date departureDate = mDetFine.group(3) != null ? ParserUtils.parseDate(mDetFine.group(3)) : null; @@ -298,6 +300,8 @@ public class SbbProvider implements NetworkProvider final String lineType = mDetFine.group(6); + final int arrivalId = mDetFine.group(9) != null ? Integer.parseInt(mDetFine.group(9)) : 0; + final String arrival = ParserUtils.resolveEntities(mDetFine.group(10)); Date arrivalDate = mDetFine.group(11) != null ? ParserUtils.parseDate(mDetFine.group(11)) : null; @@ -308,7 +312,8 @@ public class SbbProvider implements NetworkProvider if (!lineType.equals("fuss") && !lineType.equals("transfer")) { - final int departureId = Integer.parseInt(mDetFine.group(1)); + if (departureId == 0) + throw new IllegalStateException("departureId"); final Date departureTime = ParserUtils.joinDateTime(departureDate, ParserUtils.parseTime(mDetFine.group(4))); @@ -316,7 +321,8 @@ public class SbbProvider implements NetworkProvider final String line = normalizeLine(lineType, ParserUtils.resolveEntities(mDetFine.group(7))); - final int arrivalId = Integer.parseInt(mDetFine.group(9)); + if (arrivalId == 0) + throw new IllegalStateException("arrivalId"); final Date arrivalTime = ParserUtils.joinDateTime(arrivalDate, ParserUtils.parseTime(mDetFine.group(12))); @@ -330,7 +336,7 @@ public class SbbProvider implements NetworkProvider { final int min = Integer.parseInt(mDetFine.group(8)); - final Connection.Footway footway = new Connection.Footway(min, departure, arrival); + final Connection.Footway footway = new Connection.Footway(min, departureId, departure, arrivalId, arrival); connection.parts.add(footway); } } diff --git a/src/de/schildbach/pte/VbbProvider.java b/src/de/schildbach/pte/VbbProvider.java index a94e60a2..a5bda705 100644 --- a/src/de/schildbach/pte/VbbProvider.java +++ b/src/de/schildbach/pte/VbbProvider.java @@ -458,11 +458,12 @@ public final class VbbProvider implements NetworkProvider if (parts.size() > 0 && parts.get(parts.size() - 1) instanceof Connection.Footway) { final Connection.Footway lastFootway = (Connection.Footway) parts.remove(parts.size() - 1); - parts.add(new Connection.Footway(lastFootway.min + Integer.parseInt(min), lastFootway.departure, arrival)); + parts.add(new Connection.Footway(lastFootway.min + Integer.parseInt(min), lastFootway.departureId, lastFootway.departure, + arrivalId, arrival)); } else { - parts.add(new Connection.Footway(Integer.parseInt(min), departure, arrival)); + parts.add(new Connection.Footway(Integer.parseInt(min), departureId, departure, arrivalId, arrival)); } lastArrival = arrival;