Fixed weird transfer behavior

This commit is contained in:
dkeen@dkeen-laptop 2012-07-17 19:20:18 -07:00
parent ab7ab0a491
commit 41a4fc9932
3 changed files with 12 additions and 18 deletions

View File

@ -233,7 +233,7 @@ public class Departure implements Parcelable, Comparable<Departure> {
public String getEstimatedArrivalMinutesLeftText() { public String getEstimatedArrivalMinutesLeftText() {
long minutesLeft = getEstimatedArrivalMinutesLeft(); long minutesLeft = getEstimatedArrivalMinutesLeft();
if (minutesLeft < 0) { if (minutesLeft < 0) {
return "Arrived"; return "Arrived at destination";
} else if (minutesLeft == 0) { } else if (minutesLeft == 0) {
return "Estimated arrival in < 1 min."; return "Estimated arrival in < 1 min.";
} else if (minutesLeft == 1) { } else if (minutesLeft == 1) {

View File

@ -2,9 +2,7 @@ package com.dougkeen.bart.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import android.util.Log; import android.util.Log;
@ -202,18 +200,6 @@ public enum Station {
public List<Route> getTransferRoutes(Station dest) { public List<Route> getTransferRoutes(Station dest) {
List<Route> returnList = new ArrayList<Route>(); List<Route> returnList = new ArrayList<Route>();
/**
* Kind of gimpy logic... no transfers from lake or 12th if headed to
* somewhere between woak and daly
*/
if (this.equals(LAKE) || this.equals(_12TH)) {
int destIndex = Line.BLUE.stations.indexOf(dest);
if (destIndex >= Line.BLUE.stations.indexOf(DALY)
&& destIndex <= Line.BLUE.stations.indexOf(WOAK)) {
return returnList;
}
}
if (dest.getInboundTransferStation() != null) { if (dest.getInboundTransferStation() != null) {
// Try getting to the destination's inbound xfer station first // Try getting to the destination's inbound xfer station first
returnList.addAll(getDirectRoutesForDestination(this, returnList.addAll(getDirectRoutesForDestination(this,

View File

@ -11,16 +11,15 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.methods.HttpUriRequest;
import org.xml.sax.SAXException;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import android.util.Xml; import android.util.Xml;
import com.dougkeen.bart.model.Constants; import com.dougkeen.bart.model.Constants;
import com.dougkeen.bart.model.StationPair;
import com.dougkeen.bart.model.RealTimeDepartures; import com.dougkeen.bart.model.RealTimeDepartures;
import com.dougkeen.bart.model.Route; import com.dougkeen.bart.model.Route;
import com.dougkeen.bart.model.StationPair;
public abstract class GetRealTimeDeparturesTask extends public abstract class GetRealTimeDeparturesTask extends
AsyncTask<StationPair, Integer, RealTimeDepartures> { AsyncTask<StationPair, Integer, RealTimeDepartures> {
@ -50,7 +49,16 @@ public abstract class GetRealTimeDeparturesTask extends
mRoutes = params.getOrigin().getDirectRoutesForDestination( mRoutes = params.getOrigin().getDirectRoutesForDestination(
params.getDestination()); params.getDestination());
if (mRoutes.isEmpty() || params.getOrigin().transferFriendly) { boolean hasDirectLine = false;
for (Route route : mRoutes) {
if (!route.hasTransfer()) {
hasDirectLine = true;
break;
}
}
if (mRoutes.isEmpty()
|| (params.getOrigin().transferFriendly && !hasDirectLine)) {
mRoutes.addAll(params.getOrigin().getTransferRoutes( mRoutes.addAll(params.getOrigin().getTransferRoutes(
params.getDestination())); params.getDestination()));
} }