From e7ec1f59787b309f715a9f7bc658cd25c36b80c3 Mon Sep 17 00:00:00 2001 From: "dkeen@dkeen-laptop" Date: Sun, 29 Apr 2012 09:42:54 -0700 Subject: [PATCH] Various routing fixes/refactoring --- AndroidManifest.xml | 6 +- src/com/dougkeen/bart/AddRouteActivity.java | 1 - .../dougkeen/bart/ViewDeparturesActivity.java | 46 +++- src/com/dougkeen/bart/model/Departure.java | 8 + src/com/dougkeen/bart/model/Line.java | 35 +-- .../bart/model/RealTimeDepartures.java | 26 ++- src/com/dougkeen/bart/model/Route.java | 27 ++- src/com/dougkeen/bart/model/ScheduleItem.java | 29 +++ src/com/dougkeen/bart/model/Station.java | 221 ++++++++++-------- .../GetRealTimeDeparturesTask.java | 7 +- .../GetScheduleInformationTask.java | 2 +- 11 files changed, 267 insertions(+), 141 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b0652e7..4f6c1d3 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="17" + android:versionName="1.2.4" > @@ -10,7 +10,7 @@ 0) { - departure.setEstimatedTripTime(localAverageLength); - } else if (!departure.hasEstimatedTripTime()) { - departure.setEstimatedTripTime(mAverageTripLength); + // Don't estimate for non-scheduled transfers + if (!departure.getRequiresTransfer()) { + if (!departure.hasEstimatedTripTime() && localAverageLength > 0) { + departure.setEstimatedTripTime(localAverageLength); + } else if (!departure.hasEstimatedTripTime()) { + departure.setEstimatedTripTime(mAverageTripLength); + } + } else if (departure.getRequiresTransfer() + && !departure.hasAnyArrivalEstimate()) { + lastUnestimatedTransfer = departure; + } + if (!departure.hasAnyArrivalEstimate()) { + departuresWithoutEstimates++; } } @@ -418,6 +446,10 @@ public class ViewDeparturesActivity extends ListActivity { getContentResolver().update(mUri, contentValues, null, null); } + + if (departuresWithoutEstimates > 0) { + scheduleScheduleInfoFetch(20000); + } } private void scheduleDepartureFetch(int millisUntilExecute) { diff --git a/src/com/dougkeen/bart/model/Departure.java b/src/com/dougkeen/bart/model/Departure.java index fa83d32..5de6867 100644 --- a/src/com/dougkeen/bart/model/Departure.java +++ b/src/com/dougkeen/bart/model/Departure.java @@ -1,5 +1,6 @@ package com.dougkeen.bart.model; +import java.text.SimpleDateFormat; import java.util.Date; import android.content.Context; @@ -179,6 +180,10 @@ public class Departure implements Parcelable, Comparable { return this.estimatedTripTime > 0; } + public boolean hasAnyArrivalEstimate() { + return this.estimatedTripTime > 0 || this.arrivalTimeOverride > 0; + } + public int getUncertaintySeconds() { return (int) (maxEstimate - minEstimate + 1000) / 2000; } @@ -367,6 +372,7 @@ public class Departure implements Parcelable, Comparable { @Override public String toString() { + java.text.DateFormat format = SimpleDateFormat.getTimeInstance(); StringBuilder builder = new StringBuilder(); builder.append(destination); if (requiresTransfer) { @@ -374,6 +380,8 @@ public class Departure implements Parcelable, Comparable { } builder.append(", "); builder.append(getCountdownText()); + builder.append(", "); + builder.append(format.format(new Date(getMeanEstimate()))); return builder.toString(); } diff --git a/src/com/dougkeen/bart/model/Line.java b/src/com/dougkeen/bart/model/Line.java index 8b5ecee..1f9ae29 100644 --- a/src/com/dougkeen/bart/model/Line.java +++ b/src/com/dougkeen/bart/model/Line.java @@ -41,30 +41,7 @@ public enum Line { Station.DALY, Station.BALB, Station.GLEN, Station._24TH, Station._16TH, Station.CIVC, Station.POWL, Station.MONT, Station.EMBR, Station.WOAK, Station.ASHB, Station.DBRK, - Station.NBRK, Station.PLZA, Station.DELN, Station.RICH), - YELLOW_GREEN_SCHEDULED_TRANSFER(true, YELLOW, GREEN, Station.MLBR, - Station.SFIA, Station.SBRN, Station.SSAN, Station.COLM, - Station.DALY, Station.BALB, Station.GLEN, Station._24TH, - Station._16TH, Station.CIVC, Station.POWL, Station.MONT, - Station.EMBR, Station.WOAK, Station.LAKE, Station.FTVL, - Station.COLS, Station.SANL, Station.BAYF, Station.HAYW, - Station.SHAY, Station.UCTY, Station.FRMT), - YELLOW_BLUE_SCHEDULED_TRANSFER(true, YELLOW, BLUE, Station.MLBR, - Station.SFIA, Station.SBRN, Station.SSAN, Station.COLM, - Station.DALY, Station.BALB, Station.GLEN, Station._24TH, - Station._16TH, Station.CIVC, Station.POWL, Station.MONT, - Station.EMBR, Station.WOAK, Station.LAKE, Station.FTVL, - Station.COLS, Station.SANL, Station.BAYF, Station.CAST, - Station.WDUB, Station.DUBL), - YELLOW_RED_SCHEDULED_TRANSFER(YELLOW, RED, Station.MLBR, Station.SFIA, - Station.SBRN, Station.SSAN, Station.COLM, Station.DALY, - Station.BALB, Station.GLEN, Station._24TH, Station._16TH, - Station.CIVC, Station.POWL, Station.MONT, Station.EMBR, - Station.WOAK, Station.ASHB, Station.DBRK, Station.NBRK, - Station.PLZA, Station.DELN, Station.RICH), - ORANGE_BLUE_SCHEDULED_TRANSFER(true, ORANGE, BLUE, Station.FRMT, - Station.UCTY, Station.SHAY, Station.HAYW, Station.BAYF, - Station.CAST, Station.WDUB, Station.DUBL); + Station.NBRK, Station.PLZA, Station.DELN, Station.RICH); public final List stations; @@ -112,6 +89,16 @@ public enum Line { return lines; } + public static Collection getLinesWithStations(Station station1, Station station2) { + Collection lines = new ArrayList(); + for (Line line : Line.values()) { + if (line.stations.contains(station1) && line.stations.contains(station2)) { + lines.add(line); + } + } + return lines; + } + public static Set getPotentialDestinations(Station station) { Set destinations = new TreeSet(); diff --git a/src/com/dougkeen/bart/model/RealTimeDepartures.java b/src/com/dougkeen/bart/model/RealTimeDepartures.java index 0d62bd4..60341ed 100644 --- a/src/com/dougkeen/bart/model/RealTimeDepartures.java +++ b/src/com/dougkeen/bart/model/RealTimeDepartures.java @@ -4,13 +4,13 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; - public class RealTimeDepartures { public RealTimeDepartures(Station origin, Station destination, List routes) { this.origin = origin; this.destination = destination; this.routes = routes; + this.unfilteredDepartures = new ArrayList(); } private Station origin; @@ -19,6 +19,8 @@ public class RealTimeDepartures { private List departures; + final private List unfilteredDepartures; + private List routes; public Station getOrigin() { @@ -56,7 +58,29 @@ public class RealTimeDepartures { this.departures = departures; } + public void includeTransferRoutes() { + routes.addAll(origin.getTransferRoutes(destination)); + rebuildFilteredDepaturesCollection(); + } + + public void includeDoubleTransferRoutes() { + routes.addAll(origin.getDoubleTransferRoutes(destination)); + rebuildFilteredDepaturesCollection(); + } + + private void rebuildFilteredDepaturesCollection() { + getDepartures().clear(); + for (Departure departure : unfilteredDepartures) { + addDepartureIfApplicable(departure); + } + } + public void addDeparture(Departure departure) { + unfilteredDepartures.add(departure); + addDepartureIfApplicable(departure); + } + + private void addDepartureIfApplicable(Departure departure) { Station destination = Station.getByAbbreviation(departure .getDestinationAbbreviation()); if (departure.getLine() == null) diff --git a/src/com/dougkeen/bart/model/Route.java b/src/com/dougkeen/bart/model/Route.java index 7ce4d4c..e9ec275 100644 --- a/src/com/dougkeen/bart/model/Route.java +++ b/src/com/dougkeen/bart/model/Route.java @@ -1,9 +1,12 @@ package com.dougkeen.bart.model; +import java.util.Collection; + public class Route { private Station origin; private Station destination; - private Line line; + private Line directLine; + private Collection transferLines; private boolean requiresTransfer; private Station transferStation; private String direction; @@ -26,12 +29,20 @@ public class Route { this.destination = destination; } - public Line getLine() { - return line; + public Line getDirectLine() { + return directLine; } - public void setLine(Line line) { - this.line = line; + public void setDirectLine(Line line) { + this.directLine = line; + } + + public Collection getTransferLines() { + return transferLines; + } + + public void setTransferLines(Collection transferLines) { + this.transferLines = transferLines; } public boolean hasTransfer() { @@ -82,7 +93,7 @@ public class Route { builder.append(", destination="); builder.append(destination); builder.append(", line="); - builder.append(line); + builder.append(directLine); builder.append(", requiresTransfer="); builder.append(requiresTransfer); builder.append(", transferStation="); @@ -99,13 +110,15 @@ public class Route { public boolean trainDestinationIsApplicable(Station lineDestination, Line viaLine) { - Line routeLine = getLine(); + Line routeLine = getDirectLine(); if (routeLine.transferLine1 != null && viaLine.equals(routeLine.transferLine1)) { return true; } else if (routeLine.transferLine2 != null && viaLine.equals(routeLine.transferLine2)) { return true; + } else if (requiresTransfer && transferLines != null && !transferLines.isEmpty()) { + return transferLines.contains(viaLine); } else { int originIndex = viaLine.stations.indexOf(origin); int routeDestinationIndex = viaLine.stations.indexOf(destination); diff --git a/src/com/dougkeen/bart/model/ScheduleItem.java b/src/com/dougkeen/bart/model/ScheduleItem.java index ac18840..7d0ca96 100644 --- a/src/com/dougkeen/bart/model/ScheduleItem.java +++ b/src/com/dougkeen/bart/model/ScheduleItem.java @@ -1,5 +1,9 @@ package com.dougkeen.bart.model; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + public class ScheduleItem { public ScheduleItem() { @@ -12,6 +16,8 @@ public class ScheduleItem { this.destination = destination; } + public static final int SCHEDULE_ITEM_DEPARTURE_EQUALS_TOLERANCE = 120000; + private Station origin; private Station destination; private String fare; @@ -83,4 +89,27 @@ public class ScheduleItem { public void setTrainHeadStation(String trainHeadStation) { this.trainHeadStation = trainHeadStation; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + DateFormat format = SimpleDateFormat.getTimeInstance(); + builder.append("ScheduleItem [origin="); + builder.append(origin); + builder.append(", destination="); + builder.append(destination); + builder.append(", fare="); + builder.append(fare); + builder.append(", departureTime="); + builder.append(format.format(new Date(departureTime))); + builder.append(", arrivalTime="); + builder.append(format.format(new Date(arrivalTime))); + builder.append(", bikesAllowed="); + builder.append(bikesAllowed); + builder.append(", trainHeadStation="); + builder.append(trainHeadStation); + builder.append("]"); + return builder.toString(); + } + } diff --git a/src/com/dougkeen/bart/model/Station.java b/src/com/dougkeen/bart/model/Station.java index fb6c4d7..fc21e85 100644 --- a/src/com/dougkeen/bart/model/Station.java +++ b/src/com/dougkeen/bart/model/Station.java @@ -1,59 +1,58 @@ package com.dougkeen.bart.model; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import android.util.Log; public enum Station { - _12TH("12th", "12th St./Oakland City Center", true, false, false, "bayf"), - _16TH("16th", "16th St. Mission", false, false, false), - _19TH("19th", "19th St./Oakland", true, false, false, "bayf"), - _24TH("24th", "24th St. Mission", false, false, false), - ASHB("ashb", "Ashby", true, false, false, "mcar"), - BALB("balb", "Balboa Park", false, false, false), - BAYF("bayf", "Bay Fair", true, true, false, "mcar"), - CAST("cast", "Castro Valley", true, false, false, "bayf"), - CIVC("civc", "Civic Center", false, false, false), - COLS("cols", "Coliseum/Oakland Airport", true, true, false, "mcar"), - COLM("colm", "Colma", true, false, false, "balb", "balb"), - CONC("conc", "Concord", true, false, false, "mcar"), - DALY("daly", "Daly City", false, false, false), - DBRK("dbrk", "Downtown Berkeley", true, false, false, "mcar"), - DUBL("dubl", "Dublin/Pleasanton", true, false, true, "bayf", "bayf", true, + _12TH("12th", "12th St./Oakland City Center", false, false, "bayf", "bayf"), + _16TH("16th", "16th St. Mission", false, false), + _19TH("19th", "19th St./Oakland", false, false, "bayf", "bayf"), + _24TH("24th", "24th St. Mission", false, false), + ASHB("ashb", "Ashby", false, false, "mcar", "mcar"), + BALB("balb", "Balboa Park", false, false), + BAYF("bayf", "Bay Fair", true, false, "mcar", "mcar"), + CAST("cast", "Castro Valley", false, false, "bayf", "bayf"), + CIVC("civc", "Civic Center", false, false), + COLS("cols", "Coliseum/Oakland Airport", true, false, "mcar", "mcar"), + COLM("colm", "Colma", false, false, "balb", "balb"), + CONC("conc", "Concord", false, false, "mcar", "mcar"), + DALY("daly", "Daly City", false, false), + DBRK("dbrk", "Downtown Berkeley", false, false, "mcar", "mcar"), + DUBL("dubl", "Dublin/Pleasanton", false, true, "bayf", "bayf", true, 719999), + DELN("deln", "El Cerrito del Norte", false, false, "mcar", "mcar"), + PLZA("plza", "El Cerrito Plaza", false, false, "mcar", "mcar"), + EMBR("embr", "Embarcadero", false, false), + FRMT("frmt", "Fremont", true, true, "bayf", "bayf", true, 299999), + FTVL("ftvl", "Fruitvale", true, false, "mcar", "mcar"), + GLEN("glen", "Glen Park", false, false), + HAYW("hayw", "Hayward", true, false, "bayf", "bayf"), + LAFY("lafy", "Lafayette", false, false, "mcar", "mcar"), + LAKE("lake", "Lake Merritt", true, false, "mcar", "mcar"), + MCAR("mcar", "MacArthur", false, false, "bayf", "bayf"), + MLBR("mlbr", "Millbrae", false, true, "balb", "balb", true, 719999), + MONT("mont", "Montgomery St.", false, false), + NBRK("nbrk", "North Berkeley", false, false, "mcar", "mcar"), + NCON("ncon", "North Concord/Martinez", false, false, "mcar", "mcar"), + ORIN("orin", "Orinda", false, false, "mcar", "mcar"), + PITT("pitt", "Pittsburg/Bay Point", false, true, "mcar", "mcar", true, 719999), - DELN("deln", "El Cerrito del Norte", true, false, false, "mcar"), - PLZA("plza", "El Cerrito Plaza", true, false, false, "mcar"), - EMBR("embr", "Embarcadero", false, false, false), - FRMT("frmt", "Fremont", true, true, true, "bayf", "bayf", true, 299999), - FTVL("ftvl", "Fruitvale", true, true, false, "mcar"), - GLEN("glen", "Glen Park", false, false, false), - HAYW("hayw", "Hayward", true, true, false, "bayf"), - LAFY("lafy", "Lafayette", true, false, false, "mcar"), - LAKE("lake", "Lake Merritt", true, true, false, "mcar"), - MCAR("mcar", "MacArthur", true, false, false, "bayf"), - MLBR("mlbr", "Millbrae", true, false, true, "balb", "balb", true, 719999), - MONT("mont", "Montgomery St.", false, false, false), - NBRK("nbrk", "North Berkeley", true, false, false, "mcar"), - NCON("ncon", "North Concord/Martinez", true, false, false, "mcar"), - ORIN("orin", "Orinda", true, false, false, "mcar"), - PITT("pitt", "Pittsburg/Bay Point", true, false, true, "mcar", "mcar", - true, 719999), - PHIL("phil", "Pleasant Hill", true, false, false, "mcar"), - POWL("powl", "Powell St.", false, false, false), - RICH("rich", "Richmond", true, false, true, "mcar", "mcar", true, 299999), - ROCK("rock", "Rockridge", true, false, false, "mcar"), - SBRN("sbrn", "San Bruno", true, false, false, "balb", "balb"), - SANL("sanl", "San Leandro", true, true, false, "mcar"), - SFIA("sfia", "SFO Airport", true, false, false, "sbrn", "balb", true, - 719999), - SHAY("shay", "South Hayward", true, true, false, "bayf"), - SSAN("ssan", "South San Francisco", true, false, false, "balb", "balb"), - UCTY("ucty", "Union City", true, true, false, "bayf"), - WCRK("wcrk", "Walnut Creek", true, false, false, "mcar"), - WDUB("wdub", "West Dublin/Pleasanton", true, false, false, "bayf"), - WOAK("woak", "West Oakland", false, false, false), - SPCL("spcl", "Special", false, false, false); + PHIL("phil", "Pleasant Hill", false, false, "mcar", "mcar"), + POWL("powl", "Powell St.", false, false), + RICH("rich", "Richmond", false, true, "mcar", "mcar", true, 299999), + ROCK("rock", "Rockridge", false, false, "mcar", "mcar"), + SBRN("sbrn", "San Bruno", false, false, "balb", "balb"), + SANL("sanl", "San Leandro", true, false, "mcar", "mcar"), + SFIA("sfia", "SFO Airport", false, false, "balb", "balb", true, 719999), + SHAY("shay", "South Hayward", true, false, "bayf", "bayf"), + SSAN("ssan", "South San Francisco", false, false, "balb", "balb"), + UCTY("ucty", "Union City", true, false, "bayf", "bayf"), + WCRK("wcrk", "Walnut Creek", false, false, "mcar", "mcar"), + WDUB("wdub", "West Dublin/Pleasanton", false, false, "bayf", "bayf"), + WOAK("woak", "West Oakland", false, false), + SPCL("spcl", "Special", false, false); public final String abbreviation; public final String name; @@ -67,36 +66,35 @@ public enum Station { public final static int DEFAULT_DEPARTURE_EQUALITY_TOLERANCE = 59999; - private Station(String abbreviation, String name, boolean transferFriendly, - boolean invertDirection, boolean endOfLine) { - this(abbreviation, name, transferFriendly, invertDirection, endOfLine, - null, null, false, DEFAULT_DEPARTURE_EQUALITY_TOLERANCE); - } - - private Station(String abbreviation, String name, boolean transferFriendly, - boolean invertDirection, boolean endOfLine, String transferStation) { - this(abbreviation, name, transferFriendly, invertDirection, endOfLine, - transferStation, null, false, + private Station(String abbreviation, String name, boolean invertDirection, + boolean endOfLine) { + this(abbreviation, name, invertDirection, endOfLine, null, null, false, DEFAULT_DEPARTURE_EQUALITY_TOLERANCE); } - private Station(String abbreviation, String name, boolean transferFriendly, - boolean invertDirection, boolean endOfLine, - String inboundTransferStation, String outboundTransferStation) { - this(abbreviation, name, transferFriendly, invertDirection, endOfLine, + private Station(String abbreviation, String name, boolean invertDirection, + boolean endOfLine, String transferStation) { + this(abbreviation, name, invertDirection, endOfLine, transferStation, + null, false, DEFAULT_DEPARTURE_EQUALITY_TOLERANCE); + } + + private Station(String abbreviation, String name, boolean invertDirection, + boolean endOfLine, String inboundTransferStation, + String outboundTransferStation) { + this(abbreviation, name, invertDirection, endOfLine, inboundTransferStation, outboundTransferStation, false, DEFAULT_DEPARTURE_EQUALITY_TOLERANCE); } - private Station(String abbreviation, String name, boolean transferFriendly, - boolean invertDirection, boolean endOfLine, - String inboundTransferStation, String outboundTransferStation, - boolean longStationLinger, int departureEqualityTolerance) { + private Station(String abbreviation, String name, boolean invertDirection, + boolean endOfLine, String inboundTransferStation, + String outboundTransferStation, boolean longStationLinger, + int departureEqualityTolerance) { this.abbreviation = abbreviation; this.name = name; this.invertDirection = invertDirection; this.inboundTransferStation = inboundTransferStation; - this.transferFriendly = transferFriendly; + this.transferFriendly = outboundTransferStation != null; this.outboundTransferStation = outboundTransferStation; this.endOfLine = endOfLine; this.longStationLinger = longStationLinger; @@ -141,64 +139,95 @@ public enum Station { return false; } - public List getRoutesForDestination(Station dest) { - return getRoutesForDestination(dest, null); + public List getDirectRoutesForDestination(Station dest) { + return getDirectRoutesForDestination(this, dest, null, null); } - public List getRoutesForDestination(Station dest, - Station transferStation) { + public List getDirectRoutesForDestination(Station origin, + Station dest, Station transferStation, + Collection transferLines) { if (dest == null) return null; Boolean isNorth = null; List returnList = new ArrayList(); - for (Line line : Line.values()) { + final Collection applicableLines = Line.getLinesWithStations( + this, dest); + for (Line line : applicableLines) { int origIndex = line.stations.indexOf(this); - if (origIndex < 0) - continue; int destIndex = line.stations.indexOf(dest); - if (destIndex < 0) - continue; isNorth = (origIndex < destIndex); if (line.directionMayInvert && this.invertDirection) { isNorth = !isNorth; } Route route = new Route(); - route.setOrigin(this); - route.setDestination(dest); + route.setOrigin(origin); + route.setDirectLine(line); + if (this.equals(origin)) { + route.setDestination(dest); + } else { + // This must be the outbound transfer station + route.setDestination(origin.getOutboundTransferStation()); + route.setTransferLines(transferLines); + } route.setDirection(isNorth ? "n" : "s"); - route.setLine(line); if (transferStation != null || line.requiresTransfer) { route.setTransfer(true); } else { route.setTransfer(false); } - if (route.hasTransfer() && !transferFriendly - && !Line.YELLOW_ORANGE_SCHEDULED_TRANSFER.equals(line)) { - continue; - } - returnList.add(route); } - if (isNorth == null) { - if (outboundTransferStation != null) { - returnList.addAll(getOutboundTransferStation() - .getRoutesForDestination(dest, - getOutboundTransferStation())); - } else if (dest.getInboundTransferStation() != null) { - final List routesForDestination = getRoutesForDestination( - dest.getInboundTransferStation(), - dest.getInboundTransferStation()); - if (routesForDestination != null - && !routesForDestination.isEmpty()) { - returnList.addAll(routesForDestination); - } + return returnList; + } + + public List getTransferRoutes(Station dest) { + List returnList = new ArrayList(); + if (dest.getInboundTransferStation() != null) { + // Try getting to the destination's inbound xfer station first + returnList.addAll(getDirectRoutesForDestination(this, + dest.getInboundTransferStation(), + dest.getInboundTransferStation(), null)); + } + + if (returnList.isEmpty() && outboundTransferStation != null) { + // Try getting from the outbound transfer station to the + // destination next + final Collection outboundTransferLines = Line + .getLinesWithStations(this, getOutboundTransferStation()); + final List routesForDestination = getOutboundTransferStation() + .getDirectRoutesForDestination(this, dest, + getOutboundTransferStation(), outboundTransferLines); + if (routesForDestination != null && !routesForDestination.isEmpty()) { + returnList.addAll(routesForDestination); } } + + if (returnList.isEmpty()) { + // Try getting from the outbound transfer station to the + // destination's inbound xfer station + final List routesForDestination = getDoubleTransferRoutes(dest); + if (routesForDestination != null && !routesForDestination.isEmpty()) { + returnList.addAll(routesForDestination); + } + } + return returnList; } + public List getDoubleTransferRoutes(Station dest) { + if (getOutboundTransferStation() == null + || dest.getInboundTransferStation() == null) + return new ArrayList(); + + // Get routes from the outbound transfer station to the + // destination's inbound xfer station + return getOutboundTransferStation().getDirectRoutesForDestination(this, + dest.getInboundTransferStation(), getOutboundTransferStation(), + Line.getLinesWithStations(this, getOutboundTransferStation())); + } + static public List getStationList() { List list = new ArrayList(); for (Station station : values()) { diff --git a/src/com/dougkeen/bart/networktasks/GetRealTimeDeparturesTask.java b/src/com/dougkeen/bart/networktasks/GetRealTimeDeparturesTask.java index 2eb5e1e..ec76317 100644 --- a/src/com/dougkeen/bart/networktasks/GetRealTimeDeparturesTask.java +++ b/src/com/dougkeen/bart/networktasks/GetRealTimeDeparturesTask.java @@ -40,9 +40,14 @@ public abstract class GetRealTimeDeparturesTask extends // Always expect one param StationPair params = paramsArray[0]; - mRoutes = params.getOrigin().getRoutesForDestination( + mRoutes = params.getOrigin().getDirectRoutesForDestination( params.getDestination()); + if (mRoutes.isEmpty() || params.getOrigin().transferFriendly) { + mRoutes.addAll(params.getOrigin().getTransferRoutes( + params.getDestination())); + } + if (!isCancelled()) { return getDeparturesFromNetwork(params, 0); } else { diff --git a/src/com/dougkeen/bart/networktasks/GetScheduleInformationTask.java b/src/com/dougkeen/bart/networktasks/GetScheduleInformationTask.java index f8eb974..7774385 100644 --- a/src/com/dougkeen/bart/networktasks/GetScheduleInformationTask.java +++ b/src/com/dougkeen/bart/networktasks/GetScheduleInformationTask.java @@ -24,7 +24,7 @@ public abstract class GetScheduleInformationTask extends AsyncTask { private final static String SCHED_URL = "http://api.bart.gov/api/sched.aspx?cmd=depart&key=" - + Constants.API_KEY + "&orig=%1$s&dest=%2$s&b=1&a=5"; + + Constants.API_KEY + "&orig=%1$s&dest=%2$s&b=1&a=4"; private final static int MAX_ATTEMPTS = 5;