aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/DataManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/DataManager.java')
-rw-r--r--src/net/cbaines/suma/DataManager.java52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index 1658cb5..4d948ed 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.SQLException;
+import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -314,7 +315,7 @@ public class DataManager {
boolean uniLink;
int id = Integer.parseInt(dataBits[0]);
- if (id == 326 || id == 468 || id == 327 || id == 329 || id == 354) {
+ if (id == 326 || id == 468 || id == 327 || id == 329 || id == 354 || id == 999) {
uniLink = true;
} else {
uniLink = false;
@@ -331,6 +332,9 @@ public class DataManager {
} else if (id == 327) { // U6
route.forwardDirection = "H";
route.reverseDirection = "C";
+ } else if (id == 999) { // U6
+ route.forwardDirection = "E";
+ route.reverseDirection = "C";
}
// Log.i(TAG, "Loaded route " + route.id + " " + route.code +
@@ -394,6 +398,9 @@ public class DataManager {
} else if (busRoute.id == 354) { // U9
busStop.routes = (byte) (busStop.routes | (1 << 4));
busStop.uniLink = true;
+ } else if (busRoute.id == 999) { // U1E
+ busStop.routes = (byte) (busStop.routes | (1 << 5));
+ busStop.uniLink = true;
}
// Log.v(TAG, "Stop routes " + busStop.routes);
@@ -526,11 +533,13 @@ public class DataManager {
if (tempRoute.code.equals(name)) {
route = tempRoute;
dir = null;
+ break;
}
} else if (name.equals("U1E")) {
- if (tempRoute.code.equals("U1")) {
+ if (tempRoute.code.equals(name)) {
route = tempRoute;
- dir = "E";
+ dir = null;
+ break;
}
} else {
if (tempRoute.code.equals(name.substring(0, 2))) {
@@ -544,12 +553,14 @@ public class DataManager {
dir = null;
return null;
}
+ break;
}
}
} else {
if (tempRoute.code.equals(name)) {
route = tempRoute;
dir = null;
+ break;
}
}
}
@@ -671,6 +682,10 @@ public class DataManager {
if (route != null) {
busRoutes.add(route);
+
+ if (route.id == 326) { // U1
+ busRoutes.add(busRouteDao.queryForId(999));
+ }
} else {
Log.e(TAG, "Route not found " + key.substring(key.length() - 3, key.length()) + " " + key);
throw new RuntimeException("Route not found " + key.substring(key.length() - 3, key.length()) + " " + key);
@@ -863,19 +878,17 @@ public class DataManager {
String direction = "";
if (route.id == 326) { // U1
- Log.i(TAG, "Direction for " + busStopRouteIndex + " is");
- if (busStopRouteIndex >= 0 && busStopRouteIndex <= 35) {
+ if (busStopRouteIndex >= 0 && busStopRouteIndex <= 34) {
direction = route.forwardDirection;
- } else if (busStopRouteIndex >= 52 && busStopRouteIndex <= 87) {
+ } else if (busStopRouteIndex >= 35 && busStopRouteIndex <= 73) {
direction = route.reverseDirection;
} else {
Log.e(TAG, "For U1 route, error with busStopRouteIndex " + busStopRouteIndex + " " + busStop.description);
}
- Log.i(TAG, direction);
} else if (route.id == 468) { // U1N
// Nothing to do
} else if (route.id == 329) { // U2
- if (busStopRouteIndex >= 1 && busStopRouteIndex <= 22) {
+ if (busStopRouteIndex >= 0 && busStopRouteIndex <= 22) {
direction = route.forwardDirection;
} else if (busStopRouteIndex >= 23 && busStopRouteIndex <= 43) {
direction = route.reverseDirection;
@@ -883,7 +896,7 @@ public class DataManager {
Log.e(TAG, "For U2 route, error with busStopRouteIndex " + busStopRouteIndex);
}
} else if (route.id == 327) { // U6
- if (busStopRouteIndex >= 1 && busStopRouteIndex <= 44) {
+ if (busStopRouteIndex >= 0 && busStopRouteIndex <= 44) {
direction = route.forwardDirection;
} else if (busStopRouteIndex >= 45 && busStopRouteIndex <= 93) {
direction = route.reverseDirection;
@@ -892,6 +905,14 @@ public class DataManager {
}
} else if (route.id == 354) { // U9
// Arggghh!!!!
+ } else if (route.id == 999) { // U1E
+ if (busStopRouteIndex >= 0 && busStopRouteIndex <= 43) {
+ direction = route.forwardDirection;
+ } else if (busStopRouteIndex >= 45 && busStopRouteIndex <= 87) {
+ direction = route.reverseDirection;
+ } else {
+ Log.e(TAG, "For U1 route, error with busStopRouteIndex " + busStopRouteIndex + " " + busStop.description);
+ }
} else {
Log.e(TAG, "Error, unrecognised route " + route.id);
}
@@ -913,19 +934,22 @@ public class DataManager {
for (int stopNum = 0; stopNum < stopsArray.length(); stopNum++) {
JSONObject stopObj = stopsArray.getJSONObject(stopNum);
- // Log.v(TAG, "stopObj: " + stopObj);
+ Log.v(TAG, busID + " " + route.code + direction + " stopObj: " + stopObj);
if (stopObj.has("vehicle") && stopObj.getString("vehicle").equals(busID)
&& stopObj.getString("name").equals(route.code + direction)) {
stop = getStop(context, stopObj, busRoutes, busStop, age);
break;
-
- // Log.v(TAG, "Found stop for a unidentified " +
- // stop.bus.toString() + " at " + stop.busStop.id + " at "
- // + stop.arivalTime);
}
}
+ if (stop.arivalTime != null) {
+ Log.i(TAG, "Returning stop for " + stop.busStop.description + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime));
+ } else {
+ Log.i(TAG, "Returning stop for " + stop.busStop.description + " at null");
+ }
+
return stop;
}