Fixed requery intervals. Updated no results text. Updated handling for SPCL trains.
This commit is contained in:
parent
ca8f07b30a
commit
114dd4c6f4
@ -3,8 +3,7 @@
|
|||||||
<string name="app_name">BART Catcher</string>
|
<string name="app_name">BART Catcher</string>
|
||||||
<string name="favorite_routes">Favorite Routes</string>
|
<string name="favorite_routes">Favorite Routes</string>
|
||||||
<string name="empty_favorites_list_message">Press the menu button and select \"Add route\" to
|
<string name="empty_favorites_list_message">Press the menu button and select \"Add route\" to
|
||||||
add
|
add a route</string>
|
||||||
a route</string>
|
|
||||||
<string name="add_route">Add a route</string>
|
<string name="add_route">Add a route</string>
|
||||||
<string name="origin">Origin</string>
|
<string name="origin">Origin</string>
|
||||||
<string name="destination">Destination</string>
|
<string name="destination">Destination</string>
|
||||||
@ -16,7 +15,8 @@
|
|||||||
<string name="departure_wait_message">Please wait while real time departure data is
|
<string name="departure_wait_message">Please wait while real time departure data is
|
||||||
loaded...</string>
|
loaded...</string>
|
||||||
<string name="no_data_message">No departure data is currently available for this
|
<string name="no_data_message">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/</string>
|
http://m.bart.gov/schedules/advisories/</string>
|
||||||
<string name="view">View</string>
|
<string name="view">View</string>
|
||||||
<string name="view_departures">View departures</string>
|
<string name="view_departures">View departures</string>
|
||||||
|
@ -36,8 +36,6 @@ public class EtdContentHandler extends DefaultHandler {
|
|||||||
private Departure currentDeparture;
|
private Departure currentDeparture;
|
||||||
private boolean isParsingTag;
|
private boolean isParsingTag;
|
||||||
|
|
||||||
private boolean getDestinationFromLine;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void characters(char[] ch, int start, int length)
|
public void characters(char[] ch, int start, int length)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
@ -54,14 +52,10 @@ public class EtdContentHandler extends DefaultHandler {
|
|||||||
}
|
}
|
||||||
if (localName.equals("estimate")) {
|
if (localName.equals("estimate")) {
|
||||||
currentDeparture = new Departure();
|
currentDeparture = new Departure();
|
||||||
if (currentDestination.equalsIgnoreCase("SPCL")) {
|
|
||||||
getDestinationFromLine = true;
|
|
||||||
} else {
|
|
||||||
currentDeparture.setDestination(Station
|
currentDeparture.setDestination(Station
|
||||||
.getByAbbreviation(currentDestination));
|
.getByAbbreviation(currentDestination));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, String localName, String qName)
|
public void endElement(String uri, String localName, String qName)
|
||||||
@ -86,14 +80,7 @@ public class EtdContentHandler extends DefaultHandler {
|
|||||||
currentDeparture.setTrainLength(Integer.parseInt(currentValue));
|
currentDeparture.setTrainLength(Integer.parseInt(currentValue));
|
||||||
} else if (localName.equals("color")) {
|
} else if (localName.equals("color")) {
|
||||||
try {
|
try {
|
||||||
if (getDestinationFromLine) {
|
if (currentValue.equalsIgnoreCase("WHITE")) {
|
||||||
final Line line = Line.valueOf(currentValue);
|
|
||||||
currentDeparture.setLine(line);
|
|
||||||
currentDeparture.setDestination(line
|
|
||||||
.getUsualTerminusForDirectionAndOrigin(
|
|
||||||
currentDeparture.getDirection(),
|
|
||||||
realTimeDepartures.getOrigin()));
|
|
||||||
} else if (currentValue.equalsIgnoreCase("WHITE")) {
|
|
||||||
for (Line line : Line.values()) {
|
for (Line line : Line.values()) {
|
||||||
if (line.stations.indexOf(currentDeparture
|
if (line.stations.indexOf(currentDeparture
|
||||||
.getDestination()) >= 0
|
.getDestination()) >= 0
|
||||||
@ -118,7 +105,6 @@ public class EtdContentHandler extends DefaultHandler {
|
|||||||
} else if (localName.equals("estimate")) {
|
} else if (localName.equals("estimate")) {
|
||||||
realTimeDepartures.addDeparture(currentDeparture);
|
realTimeDepartures.addDeparture(currentDeparture);
|
||||||
currentDeparture = null;
|
currentDeparture = null;
|
||||||
getDestinationFromLine = false;
|
|
||||||
} else if (localName.equals("etd")) {
|
} else if (localName.equals("etd")) {
|
||||||
currentDestination = null;
|
currentDestination = null;
|
||||||
} else if (localName.equals("station")) {
|
} else if (localName.equals("station")) {
|
||||||
|
@ -92,22 +92,4 @@ public enum Line {
|
|||||||
|
|
||||||
return destinations;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -244,10 +244,8 @@ public class ViewDeparturesActivity extends ListActivity {
|
|||||||
} else {
|
} else {
|
||||||
// Get more 90 seconds before next train arrives, right when
|
// Get more 90 seconds before next train arrives, right when
|
||||||
// next train arrives, or 3 minutes, whichever is sooner
|
// next train arrives, or 3 minutes, whichever is sooner
|
||||||
final long now = System.currentTimeMillis();
|
final int intervalUntilNextDeparture = firstDeparture
|
||||||
final long nextDepartureMillis = firstDeparture
|
.getMinSecondsLeft() * 1000;
|
||||||
.getMinSecondsLeft() * 1000L;
|
|
||||||
final int intervalUntilNextDeparture = (int) (nextDepartureMillis - now);
|
|
||||||
final int alternativeInterval = 3 * 60 * 1000;
|
final int alternativeInterval = 3 * 60 * 1000;
|
||||||
|
|
||||||
int interval = intervalUntilNextDeparture;
|
int interval = intervalUntilNextDeparture;
|
||||||
|
Loading…
Reference in New Issue
Block a user