From 114dd4c6f41133f5184225522b6d7ba5db423271 Mon Sep 17 00:00:00 2001 From: dkeen Date: Mon, 6 Jun 2011 08:42:11 -0700 Subject: [PATCH] Fixed requery intervals. Updated no results text. Updated handling for SPCL trains. --- res/values/strings.xml | 6 +++--- src/com/dougkeen/bart/EtdContentHandler.java | 18 ++---------------- src/com/dougkeen/bart/Line.java | 18 ------------------ .../dougkeen/bart/ViewDeparturesActivity.java | 6 ++---- 4 files changed, 7 insertions(+), 41 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index dcd604e..b7db35b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3,8 +3,7 @@ BART Catcher Favorite Routes Press the menu button and select \"Add route\" to - add - a route + add a route Add a route Origin Destination @@ -16,7 +15,8 @@ Please wait while real time departure data is loaded... No departure data is currently available for this - route. Note that there may be service advisories posted at + route. Note that this route may require a non-standard transfer due to + a temporary change in service. Check for service advisories posted at http://m.bart.gov/schedules/advisories/ View View departures diff --git a/src/com/dougkeen/bart/EtdContentHandler.java b/src/com/dougkeen/bart/EtdContentHandler.java index 60d84ce..adde7a8 100644 --- a/src/com/dougkeen/bart/EtdContentHandler.java +++ b/src/com/dougkeen/bart/EtdContentHandler.java @@ -36,8 +36,6 @@ public class EtdContentHandler extends DefaultHandler { private Departure currentDeparture; private boolean isParsingTag; - private boolean getDestinationFromLine; - @Override public void characters(char[] ch, int start, int length) throws SAXException { @@ -54,12 +52,8 @@ public class EtdContentHandler extends DefaultHandler { } if (localName.equals("estimate")) { currentDeparture = new Departure(); - if (currentDestination.equalsIgnoreCase("SPCL")) { - getDestinationFromLine = true; - } else { - currentDeparture.setDestination(Station + currentDeparture.setDestination(Station .getByAbbreviation(currentDestination)); - } } } @@ -86,14 +80,7 @@ public class EtdContentHandler extends DefaultHandler { currentDeparture.setTrainLength(Integer.parseInt(currentValue)); } else if (localName.equals("color")) { try { - if (getDestinationFromLine) { - final Line line = Line.valueOf(currentValue); - currentDeparture.setLine(line); - currentDeparture.setDestination(line - .getUsualTerminusForDirectionAndOrigin( - currentDeparture.getDirection(), - realTimeDepartures.getOrigin())); - } else if (currentValue.equalsIgnoreCase("WHITE")) { + if (currentValue.equalsIgnoreCase("WHITE")) { for (Line line : Line.values()) { if (line.stations.indexOf(currentDeparture .getDestination()) >= 0 @@ -118,7 +105,6 @@ public class EtdContentHandler extends DefaultHandler { } else if (localName.equals("estimate")) { realTimeDepartures.addDeparture(currentDeparture); currentDeparture = null; - getDestinationFromLine = false; } else if (localName.equals("etd")) { currentDestination = null; } else if (localName.equals("station")) { diff --git a/src/com/dougkeen/bart/Line.java b/src/com/dougkeen/bart/Line.java index 572a7e4..5fd79bb 100644 --- a/src/com/dougkeen/bart/Line.java +++ b/src/com/dougkeen/bart/Line.java @@ -92,22 +92,4 @@ public enum Line { return destinations; } - - public Station getUsualTerminusForDirectionAndOrigin(String direction, - Station origin) { - boolean isNorth = false; - if (direction.toLowerCase().startsWith("s") && directionMayInvert - && origin.invertDirection) { - isNorth = true; - } else if (direction.toLowerCase().startsWith("n") - && !(directionMayInvert && origin.invertDirection)) { - isNorth = true; - } - - if (isNorth) { - return stations.get(stations.size() - 1); - } else { - return stations.get(0); - } - } } diff --git a/src/com/dougkeen/bart/ViewDeparturesActivity.java b/src/com/dougkeen/bart/ViewDeparturesActivity.java index 5623d80..e64f66b 100644 --- a/src/com/dougkeen/bart/ViewDeparturesActivity.java +++ b/src/com/dougkeen/bart/ViewDeparturesActivity.java @@ -244,10 +244,8 @@ public class ViewDeparturesActivity extends ListActivity { } else { // Get more 90 seconds before next train arrives, right when // next train arrives, or 3 minutes, whichever is sooner - final long now = System.currentTimeMillis(); - final long nextDepartureMillis = firstDeparture - .getMinSecondsLeft() * 1000L; - final int intervalUntilNextDeparture = (int) (nextDepartureMillis - now); + final int intervalUntilNextDeparture = firstDeparture + .getMinSecondsLeft() * 1000; final int alternativeInterval = 3 * 60 * 1000; int interval = intervalUntilNextDeparture;