aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-03-15 23:11:36 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-03-15 23:11:36 +0000
commitf80e4dc8d1a08c41f1f892a606865d2507ceb978 (patch)
treed91604ce1d7c8b928c287f7cda7237fa2abcec4f
parentb64d1a19c68a703526460bec8e9a0ea22448b1b5 (diff)
downloadsouthamptonuniversitymap-f80e4dc8d1a08c41f1f892a606865d2507ceb978.tar
southamptonuniversitymap-f80e4dc8d1a08c41f1f892a606865d2507ceb978.tar.gz
Possible change to implement the U1E as a route, and not just a hack.
-rw-r--r--assets/data.dbbin487424 -> 489472 bytes
-rw-r--r--assets/routes.csv1
-rw-r--r--assets/routestops.csv73
-rw-r--r--res/layout/bus_activity.xml3
-rw-r--r--src/net/cbaines/suma/Bus.java12
-rw-r--r--src/net/cbaines/suma/BusActivity.java94
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java66
-rw-r--r--src/net/cbaines/suma/BusStopSpecificStopView.java53
-rw-r--r--src/net/cbaines/suma/DataManager.java34
-rw-r--r--src/net/cbaines/suma/DatabaseHelper.java13
-rw-r--r--src/net/cbaines/suma/MapActivity.java31
-rw-r--r--src/net/cbaines/suma/Preferences.java4
-rw-r--r--src/net/cbaines/suma/RouteColorConstants.java1
13 files changed, 163 insertions, 222 deletions
diff --git a/assets/data.db b/assets/data.db
index e8cba4c..e637c33 100644
--- a/assets/data.db
+++ b/assets/data.db
Binary files differ
diff --git a/assets/routes.csv b/assets/routes.csv
index b536ee7..7ccf180 100644
--- a/assets/routes.csv
+++ b/assets/routes.csv
@@ -42,6 +42,7 @@
479,S2,"City - Shirley via Tesco"
326,U1,"NOC - Parkway - Eastleigh"
468,U1N,"Leisure World - City Centre -"
+999,U1E,"NOC - Parkway - Eastleigh"
329,U2,"Civic Centre - Highfield Campu"
327,U6,"Dock Gate 4 - General Hospital"
354,U9,"Townhill Park - General Hospit"
diff --git a/assets/routestops.csv b/assets/routestops.csv
index 8f966b1..0c26511 100644
--- a/assets/routestops.csv
+++ b/assets/routestops.csv
@@ -3293,3 +3293,76 @@
423,69,WIA12284
423,70,WIA12274
423,71,WIA04208
+999,1,HAA13579
+999,2,SN120635
+999,3,SNA13767
+999,4,SNA13768
+999,5,HA120625
+999,6,SNA09343
+999,7,SN120553
+999,8,SN120520
+999,9,SN120527
+999,10,SN12524D
+999,11,SN120522
+999,12,SN120535
+999,13,SN120405
+999,14,SN120401
+999,15,SN120398
+999,16,SN120788
+999,17,SN120282
+999,18,SN120281
+999,19,SN120276
+999,20,SN12272A
+999,21,SN120268
+999,22,SN120267
+999,23,SN120257
+999,24,SNA19777
+999,25,SN120131
+999,26,SN120139
+999,27,SN120137
+999,28,SN120144
+999,29,HAA13379
+999,30,HAA13380
+999,31,SN120160
+999,32,HAA13650
+999,33,SN120162
+999,34,HAA13386
+999,35,SN120998
+999,36,HA030183
+999,52,HA030184
+999,53,HAA09424
+999,54,SN120999
+999,55,SN120164
+999,56,SN120163
+999,57,HAA13651
+999,58,SNA19780
+999,59,HAA13381
+999,60,SN120147
+999,61,SN120145
+999,62,SN120140
+999,63,SN120136
+999,64,SN120134
+999,65,HAA13668
+999,66,SN120256
+999,67,SN120266
+999,68,SN120269
+999,69,SN12275A
+999,70,SN120278
+999,71,SN120280
+999,72,SN120283
+999,73,SN120399
+999,74,SN120400
+999,75,SN120404
+999,76,SN120406
+999,77,SN120536
+999,78,SNA40402
+999,79,SN120525
+999,80,HAA13584
+999,81,SN120520
+999,82,SN121031
+999,83,HAA13583
+999,84,HA120626
+999,85,SNA13769
+999,86,SNA13766
+999,87,SNA09285
+999,88,MG1031
diff --git a/res/layout/bus_activity.xml b/res/layout/bus_activity.xml
index 93ad39a..aab2711 100644
--- a/res/layout/bus_activity.xml
+++ b/res/layout/bus_activity.xml
@@ -23,7 +23,8 @@
android:id="@+id/busActivityBusDestination"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceLarge" />
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:visibility="gone" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
diff --git a/src/net/cbaines/suma/Bus.java b/src/net/cbaines/suma/Bus.java
index 9894e6b..5cbf375 100644
--- a/src/net/cbaines/suma/Bus.java
+++ b/src/net/cbaines/suma/Bus.java
@@ -19,53 +19,41 @@
package net.cbaines.suma;
-import com.j256.ormlite.field.DatabaseField;
-import com.j256.ormlite.table.DatabaseTable;
-
/**
* Represents a bus
*
* @author Christopher Baines <cbaines8@gmail.com>
*
*/
-@DatabaseTable(tableName = "buses")
public class Bus {
final static String ID_FIELD_NAME = "id";
final static String ROUTE_FIELD_NAME = "route";
final static String DIRECTION_FIELD_NAME = "direction";
- @DatabaseField(generatedId = true)
- int gid;
-
/**
* The identification number of the bus.
*/
- @DatabaseField(canBeNull = true)
String id;
/**
* The route the bus is travelling.
*/
- @DatabaseField(canBeNull = false, foreign = true)
BusRoute route;
/**
* The direction which the bus is travelling.
*/
- @DatabaseField(canBeNull = true)
String direction;
/**
* The destination the bus is travelling towards.
*/
- @DatabaseField(canBeNull = true, foreign = true)
BusStop destination;
/**
* The destination the bus is travelling towards.
*/
- @DatabaseField(canBeNull = true)
String destinationString;
Bus() {
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index 85ed9f7..368d514 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -30,15 +30,15 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
final static String TAG = "BusActivity";
private TextView busIDTextView;
- private TextView busDestTextView;
+ // private TextView busDestTextView;
private TextView busContentMessage;
private LinearLayout busActivityContentLayout;
- /**
- * The bus this activity is focused on
- */
- private Bus bus;
+ private String busID;
+
+ private BusRoute busRoute;
+
/**
* The bus stop this activity is working from
*/
@@ -67,8 +67,6 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
setContentView(R.layout.bus_activity);
instance = this;
- String busID;
-
if (getIntent().getDataString().startsWith("http://data")) {
String[] uriParts = getIntent().getDataString().split("/");
busID = uriParts[uriParts.length - 1].replace(".html", "");
@@ -78,21 +76,10 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
String busStopID = getIntent().getExtras().getString("busStopID");
+ int busRouteID = getIntent().getExtras().getInt("busRouteID");
try {
final DatabaseHelper helper = getHelper();
- List<Bus> buses = helper.getBusDao().queryForEq(Bus.ID_FIELD_NAME, busID);
-
- bus = null;
- if (buses.size() == 0) {
- Log.e(TAG, "Bus " + busID + " not found!");
- } else if (buses.size() == 1) {
- bus = buses.get(0);
- } else if (buses.size() > 1) {
- Log.e(TAG, "Found more than one bus? " + busID);
- }
-
- helper.getBusRouteDao().refresh(bus.route);
busStop = null;
if (busStopID != null) {
@@ -107,53 +94,36 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
busIDTextView = (TextView) findViewById(R.id.busActivityBusID);
- busDestTextView = (TextView) findViewById(R.id.busActivityBusDestination);
+ // busDestTextView = (TextView) findViewById(R.id.busActivityBusDestination);
busContentMessage = (TextView) findViewById(R.id.busActivityMessage);
busActivityContentLayout = (LinearLayout) findViewById(R.id.busActivityContentLayout);
timetableView = (ListView) findViewById(R.id.busActivityTimes);
- if (bus.id != null) {
- // Log.i(TAG, "Bus id is not null (" + bus.id +
- // ") setting busIDTextView");
- getHelper().getBusRouteDao().refresh(bus.route);
- busIDTextView.setText(bus.id + " " + bus.route.label);
- } else {
- Log.w(TAG, "Bus id is null?");
- // Might not ever happen
- busIDTextView.setText("Unidentified");
- }
-
- if (bus.destinationString != null) {
- // Log.i(TAG, "Bus destination string is " +
- // bus.destinationString);
- busDestTextView
- .setText(getResources().getString(R.string.bus_activity_destination_label) + bus.destinationString);
- busDestTextView.setVisibility(View.VISIBLE);
- } else {
- // Log.i(TAG, "Bus destination string is null");
- busDestTextView.setText(getResources().getString(R.string.bus_activity_no_destination_message));
- busDestTextView.setVisibility(View.VISIBLE);
- }
-
- busStops = bus.route.getRouteBusStops(this);
+ // Log.i(TAG, "Bus id is not null (" + bus.id +
+ // ") setting busIDTextView");
+ busRoute = getHelper().getBusRouteDao().queryForId(busRouteID);
+ busIDTextView.setText(busID + " " + busRoute.label);
+
+ // if (bus.destinationString != null) {
+ // // Log.i(TAG, "Bus destination string is " +
+ // // bus.destinationString);
+ // busDestTextView
+ // .setText(getResources().getString(R.string.bus_activity_destination_label) + bus.destinationString);
+ // busDestTextView.setVisibility(View.VISIBLE);
+ // } else {
+ // // Log.i(TAG, "Bus destination string is null");
+ // busDestTextView.setText(getResources().getString(R.string.bus_activity_no_destination_message));
+ // busDestTextView.setVisibility(View.VISIBLE);
+ // }
+
+ 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");
- if (bus.route.id == 326 && !bus.direction.equals("E")) {
- Log.i(TAG, "Removing extra U1 stops");
- for (int i = 35; i < 50; i++) {
- Log.i(TAG, "Removing " + busStops.get(35).description);
- busStops.remove(35);
- busStopRoutePositions.remove(35);
- }
- } else {
- Log.i(TAG, "Not removing extra U1 stops");
- }
-
refreshData = new Runnable() {
public void run() {
Log.v(TAG, "Refreshing data " + (System.currentTimeMillis() - timeOfLastRefresh));
@@ -192,10 +162,8 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
// Remove the old time from the timetable
synchronized (timetable) {
- timetable.set(
- index,
- new StopLoading(bus, busStops.get(index), timetable.get(index).arivalTime, new Date(System
- .currentTimeMillis() - 21000), false));
+ timetable.set(index, new StopLoading(timetable.get(index).bus, busStops.get(index),
+ timetable.get(index).arivalTime, new Date(System.currentTimeMillis() - 21000), false));
displayTimetable();
}
@@ -229,8 +197,8 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
for (int i = 0; i < busStops.size(); i++) {
// Add a loading stop, with a fetch time such that it will
// be fetched
- timetable
- .add(new StopLoading(bus, busStops.get(i), null, new Date(System.currentTimeMillis() - 21000), false));
+ timetable.add(new StopLoading(null, busStops.get(i), null, new Date(System.currentTimeMillis() - 21000),
+ false));
}
// Log.v(TAG, "Finished adding placeholder stops");
} else {
@@ -309,9 +277,9 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
try {
// Log.i(TAG, "Fetching stop for busStop " + busStop.description);
- stop = DataManager.getStop(instance, bus, busStopRoutePositions.get(busStopIndex));
+ stop = DataManager.getStop(instance, busID, busRoute, busStopRoutePositions.get(busStopIndex));
if (stop == null) {
- stop = new Stop(bus, busStop, null, new Date(System.currentTimeMillis()), false);
+ stop = new Stop(null, busStop, null, new Date(System.currentTimeMillis()), false);
}
// Log.i(TAG, "Finished fetching stop for busStop " + stop.busStop.description + " " + busStop.description);
} catch (SQLException e) {
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index 7252802..a939cde 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -19,7 +19,6 @@
package net.cbaines.suma;
-import java.sql.SQLException;
import java.text.DateFormat;
import android.app.Activity;
@@ -36,9 +35,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
-import com.j256.ormlite.android.apptools.OpenHelperManager;
-import com.j256.ormlite.dao.Dao;
-
public class BusSpecificStopView extends LinearLayout implements OnClickListener, OnLongClickListener {
private static final String TAG = "BusSpecificStopView";
@@ -106,26 +102,16 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
time.setText("");
}
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
-
- try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
-
- busDao.refresh(stop.bus);
-
- if (stop.arivalTime != null) {
- if (stop.live) {
- onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- } else {
- onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)";
- }
+ if (stop.arivalTime != null) {
+ if (stop.live) {
+ onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
} else {
- onClickMessage = stop.busStop.description + " on route, but arival time is not avalible";
+ onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)";
}
- } catch (SQLException e) {
- e.printStackTrace();
+ } else {
+ onClickMessage = stop.busStop.description + " on route, but arival time is not avalible";
}
this.setOnClickListener(this);
@@ -133,14 +119,6 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
}
public void onClick(View v) {
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
- try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
- busDao.refresh(stop.bus);
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
if (stop.bus.id != null) {
context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
} else {
@@ -149,28 +127,18 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
}
public boolean onLongClick(View v) { // TODO
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
-
- try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
-
- busDao.refresh(stop.bus);
-
- if (stop.bus.id != null) {
- Uri uri = Uri.parse("geo:" + Util.E6IntToDouble(stop.busStop.point.getLatitudeE6()) + ","
- + Util.E6IntToDouble(stop.busStop.point.getLongitudeE6()) + "?z=18");
-
- Log.i(TAG, "Starting a activity for " + uri);
+ if (stop.bus.id != null) {
+ Uri uri = Uri.parse("geo:" + Util.E6IntToDouble(stop.busStop.point.getLatitudeE6()) + ","
+ + Util.E6IntToDouble(stop.busStop.point.getLongitudeE6()) + "?z=18");
- Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
- ((Activity) context).startActivity(mapIntent);
- } else {
- context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT);
- }
+ Log.i(TAG, "Starting a activity for " + uri);
- } catch (SQLException e) {
- e.printStackTrace();
+ Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
+ ((Activity) context).startActivity(mapIntent);
+ } else {
+ context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT);
}
+
return false;
}
}
diff --git a/src/net/cbaines/suma/BusStopSpecificStopView.java b/src/net/cbaines/suma/BusStopSpecificStopView.java
index eade3fe..635d2e8 100644
--- a/src/net/cbaines/suma/BusStopSpecificStopView.java
+++ b/src/net/cbaines/suma/BusStopSpecificStopView.java
@@ -70,8 +70,7 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
Resources resources = context.getResources();
onClickHelpMessage = resources.getString(R.string.bus_stop_stop_view_on_click_toast_help_message);
- onClickUnidentifiedMessage = resources
- .getString(R.string.bus_stop_stop_view_on_click_toast_unidentified_message);
+ onClickUnidentifiedMessage = resources.getString(R.string.bus_stop_stop_view_on_click_toast_unidentified_message);
setStop(stop);
@@ -88,32 +87,22 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
name.setText(stop.bus.getName());
time.setText(stop.getTimeToArival());
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
-
- try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
-
- busDao.refresh(stop.bus);
-
- if (stop.bus.id != null) {
- if (stop.live) {
- onClickMessage = "Bus " + stop.bus.toString() + " at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- } else {
- onClickMessage = "Timetabled bus " + stop.bus.toString() + " at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- }
+ if (stop.bus.id != null) {
+ if (stop.live) {
+ onClickMessage = "Bus " + stop.bus.toString() + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
} else {
- if (stop.live) {
- onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- } else {
- onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- }
+ onClickMessage = "Timetabled bus " + stop.bus.toString() + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
+ }
+ } else {
+ if (stop.live) {
+ onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
+ } else {
+ onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
}
- } catch (SQLException e) {
- e.printStackTrace();
}
this.setOnClickListener(this);
@@ -122,13 +111,6 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
public void onClick(View v) {
Log.v(TAG, "onClick");
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
- try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
- busDao.refresh(stop.bus);
- } catch (SQLException e) {
- e.printStackTrace();
- }
if (stop.bus.id != null) {
Log.v(TAG, "stop.bus != null");
@@ -143,14 +125,11 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao();
- busDao.refresh(stop.bus);
busRouteDao.refresh(stop.bus.route);
- Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID "
- + stop.bus.id);
+ Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID " + stop.bus.id);
if (stop.bus.id != null && stop.bus.route.uniLink) {
Uri uri = Uri.parse("http://id.southampton.ac.uk/bus/" + stop.bus.id);
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index 6f35453..984832c 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -491,8 +491,6 @@ public class DataManager {
routeStopsDao = helper.getRouteStopsDao();
if (busStopDao == null)
busStopDao = helper.getBusStopDao();
- if (busDao == null)
- busDao = helper.getBusDao();
String time = stopObj.getString("time");
@@ -866,8 +864,8 @@ public class DataManager {
return stop;
}
- public static Stop getStop(Context context, Bus bus, int busStopRouteIndex) throws SQLException, ClientProtocolException,
- IOException, JSONException {
+ public static Stop getStop(Context context, String busID, BusRoute route, int busStopRouteIndex) throws SQLException,
+ ClientProtocolException, IOException, JSONException {
if (helper == null)
helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
@@ -876,9 +874,6 @@ public class DataManager {
if (busStopDao == null)
busStopDao = helper.getBusStopDao();
- busRouteDao.refresh(bus.route);
- BusRoute route = bus.route;
-
List<BusStop> busStops = route.getRouteBusStops(context);
BusStop busStop = busStops.get(busStopRouteIndex);
@@ -888,19 +883,15 @@ public class DataManager {
String direction = "";
if (route.id == 326) { // U1
- if (bus.direction.equals("E")) {
- direction = "E";
+ Log.i(TAG, "Direction for " + busStopRouteIndex + " is");
+ if (busStopRouteIndex >= 0 && busStopRouteIndex <= 36) {
+ direction = route.forwardDirection;
+ } else if (busStopRouteIndex >= 50 && busStopRouteIndex <= 87) {
+ direction = route.reverseDirection;
} else {
- Log.i(TAG, "Direction for " + busStopRouteIndex + " is");
- if (busStopRouteIndex >= 0 && busStopRouteIndex <= 36) {
- direction = route.forwardDirection;
- } else if (busStopRouteIndex >= 50 && busStopRouteIndex <= 87) {
- direction = route.reverseDirection;
- } else {
- Log.e(TAG, "For U1 route, error with busStopRouteIndex " + busStopRouteIndex);
- }
- Log.i(TAG, direction);
+ Log.e(TAG, "For U1 route, error with busStopRouteIndex " + busStopRouteIndex);
}
+ Log.i(TAG, direction);
} else if (route.id == 468) { // U1N
// Nothing to do
} else if (route.id == 329) { // U2
@@ -929,8 +920,7 @@ public class DataManager {
JSONArray stopsArray = data.getJSONArray("stops");
HashSet<BusRoute> busRoutes = new HashSet<BusRoute>();
- busRouteDao.refresh(bus.route);
- busRoutes.add(bus.route);
+ busRoutes.add(route);
int age = Integer.parseInt(data.getString("age"));
@@ -944,8 +934,8 @@ public class DataManager {
JSONObject stopObj = stopsArray.getJSONObject(stopNum);
// Log.v(TAG, "stopObj: " + stopObj);
- if (stopObj.has("vehicle") && stopObj.getString("vehicle").equals(bus.id)
- && stopObj.getString("name").equals(bus.route.code + direction)) {
+ if (stopObj.has("vehicle") && stopObj.getString("vehicle").equals(busID)
+ && stopObj.getString("name").equals(route.code + direction)) {
stop = getStop(context, stopObj, busRoutes, busStop, age);
break;
diff --git a/src/net/cbaines/suma/DatabaseHelper.java b/src/net/cbaines/suma/DatabaseHelper.java
index d039518..75bf952 100644
--- a/src/net/cbaines/suma/DatabaseHelper.java
+++ b/src/net/cbaines/suma/DatabaseHelper.java
@@ -40,7 +40,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper implements Preferenc
private Dao<BusRoute, Integer> busRouteDao = null;
private Dao<RouteStop, Integer> routeStopsDao = null;
private Dao<Site, String> siteDao = null;
- private Dao<Bus, Integer> busDao = null;
volatile boolean doneUpgrade = false;
@@ -59,7 +58,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper implements Preferenc
TableUtils.createTable(connectionSource, BusRoute.class);
TableUtils.createTable(connectionSource, RouteStop.class);
TableUtils.createTable(connectionSource, Site.class);
- TableUtils.createTable(connectionSource, Bus.class);
} catch (SQLException e) {
Log.e(DatabaseHelper.class.getName(), "Can't create database", e);
@@ -125,16 +123,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper implements Preferenc
}
/**
- * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or just give the cached value.
- */
- public Dao<Bus, Integer> getBusDao() throws SQLException {
- if (busDao == null) {
- busDao = getDao(Bus.class);
- }
- return busDao;
- }
-
- /**
* Check if the database already exist to avoid re-copying the file each time you open the application.
*
* @return true if it exists, false if it doesn't
@@ -151,6 +139,5 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper implements Preferenc
busRouteDao = null;
routeStopsDao = null;
siteDao = null;
- busDao = null;
}
} \ No newline at end of file
diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java
index 58c7918..6f712e5 100644
--- a/src/net/cbaines/suma/MapActivity.java
+++ b/src/net/cbaines/suma/MapActivity.java
@@ -573,34 +573,19 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
if (pastOverlays != null
&& (routeOverlay = (PathOverlay) pastOverlays.get(BUS_ROUTE_OVERLAYS + route.code)) != null) {
Log.v(TAG, "Restored " + route.code + " route overlay");
- if (route.code.equals("U1")) {
- PathOverlay routeOverlayU1E = (PathOverlay) pastOverlays.get(BUS_ROUTE_OVERLAYS + "U1E");
- overlays.put(BUS_ROUTE_OVERLAYS + "U1E", routeOverlayU1E);
- }
+
} else {
InputStream resource = null;
int colour = 0;
if (route.code.equals("U1")) {
resource = getResources().openRawResource(R.raw.u1);
colour = U1;
-
- // TODO Is this a route like U1N or, something else,
- // this hack works somewhat for now?
- PathOverlay routeOverlayU1E = DataManager.getRoutePath(getResources().openRawResource(R.raw.u1e),
- colour, mResourceProxy);
- routeOverlayU1E.getPaint().setAntiAlias(true);
- routeOverlayU1E.getPaint().setAlpha(145);
- routeOverlayU1E.getPaint().setStrokeWidth(12);
- routeOverlayU1E.getPaint().setPathEffect(new DashPathEffect(new float[] { 20, 16 }, 0));
-
- busRouteOverlays.put(new BusRoute(1000, "U1E", "U1E Route Label", true), routeOverlayU1E);
- overlays.put(BUS_ROUTE_OVERLAYS + "U1E", routeOverlayU1E);
- synchronized (mapView.getOverlays()) {
- mapView.getOverlays().add(routeOverlayU1E);
- }
} else if (route.code.equals("U1N")) {
resource = getResources().openRawResource(R.raw.u1n);
colour = U1N;
+ } else if (route.code.equals("U1E")) {
+ resource = getResources().openRawResource(R.raw.u1e);
+ colour = U1E;
} else if (route.code.equals("U2")) {
resource = getResources().openRawResource(R.raw.u2);
colour = U2;
@@ -616,6 +601,10 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
routeOverlay = DataManager.getRoutePath(resource, colour, mResourceProxy);
+ if (route.code.equals("U1E")) {
+ routeOverlay.getPaint().setPathEffect(new DashPathEffect(new float[] { 20, 16 }, 0));
+ }
+
Log.v(TAG, "Path overlay has " + routeOverlay.getNumberOfPoints() + " points");
routeOverlay.getPaint().setAntiAlias(true);
@@ -635,10 +624,6 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
routeOverlay.setEnabled(activityPrefs.getBoolean(BUS_ROUTE_OVERLAYS + route.code,
BUS_ROUTE_OVERLAYS_ENABLED_BY_DEFAULT));
- if (route.code.equals("U1")) {
- overlays.get(BUS_ROUTE_OVERLAYS + "U1E").setEnabled(
- activityPrefs.getBoolean(BUS_ROUTE_OVERLAYS + "U1", BUS_ROUTE_OVERLAYS_ENABLED_BY_DEFAULT));
- }
mapView.postInvalidate();
diff --git a/src/net/cbaines/suma/Preferences.java b/src/net/cbaines/suma/Preferences.java
index 791aad8..8fc0cb8 100644
--- a/src/net/cbaines/suma/Preferences.java
+++ b/src/net/cbaines/suma/Preferences.java
@@ -23,11 +23,11 @@ public interface Preferences {
static final String DATABASE_PATH = "/data/data/net.cbaines.suma/databases/";
static final String DATABASE_NAME = "data.db";
- static final int DATABASE_VERSION = 42;
+ static final int DATABASE_VERSION = 43;
/**
* 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 = true;
+ static final boolean USE_BUNDLED_DATABASE = false;
}
diff --git a/src/net/cbaines/suma/RouteColorConstants.java b/src/net/cbaines/suma/RouteColorConstants.java
index 683031b..1963271 100644
--- a/src/net/cbaines/suma/RouteColorConstants.java
+++ b/src/net/cbaines/suma/RouteColorConstants.java
@@ -24,6 +24,7 @@ import android.graphics.Color;
public interface RouteColorConstants {
public final int U1 = Color.rgb(0, 139, 208);
public final int U1N = Color.rgb(0, 47, 107); // Dark blue
+ public final int U1E = Color.rgb(0, 139, 208);
public final int U2 = Color.rgb(226, 0, 26);
public final int U6 = Color.rgb(247, 168, 0);
public final int U9 = Color.rgb(231, 82, 148); // Pink