diff options
-rw-r--r-- | AndroidManifest.xml | 4 | ||||
-rw-r--r-- | assets/data.db | bin | 489472 -> 489472 bytes | |||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/net/cbaines/suma/Bus.java | 2 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusActivity.java | 13 | ||||
-rw-r--r-- | src/net/cbaines/suma/DataManager.java | 52 | ||||
-rw-r--r-- | src/net/cbaines/suma/Preferences.java | 4 |
7 files changed, 48 insertions, 29 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 24b5cd1..88d0f48 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.cbaines.suma" - android:versionCode="12" - android:versionName="0.9 (beta)" > + android:versionCode="13" + android:versionName="0.9.1 (beta)" > <uses-sdk android:minSdkVersion="8" diff --git a/assets/data.db b/assets/data.db Binary files differindex e637c33..32e1e74 100644 --- a/assets/data.db +++ b/assets/data.db diff --git a/res/values/strings.xml b/res/values/strings.xml index 208f4eb..f44fcfc 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -115,7 +115,7 @@ GNU General Public License for more details.</string> <!-- About Strings --> <string name="about">About</string> <string name="about_version">Version</string> - <string name="about_version_summary">0.9 (beta)</string> + <string name="about_version_summary">0.9.1(beta)</string> <string name="about_copyright">Copyright</string> <string name="about_copyright_summary">© 2012, Christopher Baines</string> <string name="about_license">License</string> diff --git a/src/net/cbaines/suma/Bus.java b/src/net/cbaines/suma/Bus.java index d971dac..b6986f7 100644 --- a/src/net/cbaines/suma/Bus.java +++ b/src/net/cbaines/suma/Bus.java @@ -85,7 +85,7 @@ public class Bus { } public String toString() { - return String.valueOf(id + " (" + route.code + direction + ")"); + return String.valueOf(id + " (" + getName() + ")"); } String getName() { diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java index 1659c88..532b2ca 100644 --- a/src/net/cbaines/suma/BusActivity.java +++ b/src/net/cbaines/suma/BusActivity.java @@ -2,7 +2,6 @@ package net.cbaines.suma; import java.io.IOException; import java.sql.SQLException; -import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -54,7 +53,6 @@ public class BusActivity extends ToastHelperActivity implements Preferences { // BusStops and if they are being updated by the handler List<BusStop> busStops; - ArrayList<Integer> busStopRoutePositions; private HashMap<Integer, GetTimetableStopTask> tasks = new HashMap<Integer, GetTimetableStopTask>(); @@ -103,7 +101,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences { // Log.i(TAG, "Bus id is not null (" + bus.id + // ") setting busIDTextView"); busRoute = getHelper().getBusRouteDao().queryForId(busRouteID); - busIDTextView.setText(busID + " " + busRoute.label); + busIDTextView.setText(busID + " " + busRoute.code); // if (bus.destinationString != null) { // // Log.i(TAG, "Bus destination string is " + @@ -118,10 +116,6 @@ public class BusActivity extends ToastHelperActivity implements Preferences { // } busStops = busRoute.getRouteBusStops(this); - busStopRoutePositions = new ArrayList<Integer>(); - for (int i = 0; i < busStops.size(); i++) { - busStopRoutePositions.add(i); - } // Log.i(TAG, "Got " + busStops.size() + " bus stops for this bus"); refreshData = new Runnable() { @@ -268,7 +262,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences { try { // Log.i(TAG, "Fetching stop for busStop " + busStop.description); - stop = DataManager.getStop(instance, busID, busRoute, busStopRoutePositions.get(busStopIndex)); + stop = DataManager.getStop(instance, busID, busRoute, busStopIndex); if (stop == null) { stop = new Stop(null, busStop, null, new Date(System.currentTimeMillis()), false); } @@ -291,7 +285,8 @@ public class BusActivity extends ToastHelperActivity implements Preferences { } protected void onPostExecute(Stop stop) { - if (isCancelled()) return; + if (isCancelled()) + return; synchronized (timetable) { timetable.set(busStopIndex, stop); 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; } diff --git a/src/net/cbaines/suma/Preferences.java b/src/net/cbaines/suma/Preferences.java index 8fc0cb8..368e75c 100644 --- a/src/net/cbaines/suma/Preferences.java +++ b/src/net/cbaines/suma/Preferences.java @@ -16,7 +16,7 @@ public interface Preferences { static final String APP_VERSION = "appVersion"; static final String APP_NOT_INSTALLED = ""; - static final String CURRENT_APP_VERSION = "0.9"; + static final String CURRENT_APP_VERSION = "0.9.1"; static final String FAVOURITES_PREFERENCES = "favourites"; @@ -29,5 +29,5 @@ public interface Preferences { * Enable to use the database in the assets folder, if its not enabled, the database is built from the csv files in the assets * folder */ - static final boolean USE_BUNDLED_DATABASE = false; + static final boolean USE_BUNDLED_DATABASE = true; } |