aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-18 23:37:52 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-18 23:37:52 +0000
commitc3ccc3b44f3cb272afc4c30023c922558ec928ec (patch)
treec212df7e1249a06f90e58e588c4e3ad05d1b4483 /src/net/cbaines/suma
parent8fcfee6f01df391476a884c73a8c6c9259e4165b (diff)
downloadsouthamptonuniversitymap-c3ccc3b44f3cb272afc4c30023c922558ec928ec.tar
southamptonuniversitymap-c3ccc3b44f3cb272afc4c30023c922558ec928ec.tar.gz
Working non uni link bus stop overlay :)
Diffstat (limited to 'src/net/cbaines/suma')
-rw-r--r--src/net/cbaines/suma/MapActivity.java130
-rw-r--r--src/net/cbaines/suma/Preferences.java4
-rw-r--r--src/net/cbaines/suma/PreferencesActivity.java4
3 files changed, 91 insertions, 47 deletions
diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java
index aa621da..21bcf15 100644
--- a/src/net/cbaines/suma/MapActivity.java
+++ b/src/net/cbaines/suma/MapActivity.java
@@ -78,7 +78,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
* 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
*/
- private boolean useBundledDatabase = false;
+ private boolean useBundledDatabase = true;
private MapView mapView;
private MapController mapController;
@@ -122,9 +122,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
private static final int UNI_LINK_BUS_STOP_OVERLAY_RANK = 3;
// ---- Non Uni-Link Bus Stop Overlay
- private static final String NON_UNI_LINK_BUS_STOP_OVERLAY = "nonUniLinkBusStopOverlay";
private BusStopOverlay nonUniLinkBusStopOverlay;
- static final boolean NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT = true;
private static final int NON_UNI_LINK_BUS_STOP_OVERLAY_RANK = 4;
// -- Site Overlays
@@ -749,50 +747,83 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
final OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
if (uniLinkBusStopOverlay != null) {
-
- } else {
- if (pastOverlays != null
- && (uniLinkBusStopOverlay = (BusStopOverlay) pastOverlays.get(UNI_LINK_BUS_STOP_OVERLAY)) != null) {
- Log.i(TAG, "Restored bus stop overlays");
+ if (!activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
+ Log.i(TAG, "Uni-Link bus stop overlay not needed");
+ uniLinkBusStopOverlay = null;
} else {
- try {
- List<BusStop> busStops;
- Log.v(TAG, "Begin fetching BusStops at " + (System.currentTimeMillis() - startTime));
- if (activityPrefs.getBoolean(UNI_LINK_BUS_STOP_OVERLAY,
+ uniLinkBusStopOverlay.setRoutes(0, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(1, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(2, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(3, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(4, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ }
+ } else {
+ if (activityPrefs
+ .getBoolean(BUS_STOP_OVERLAYS + "U1", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
- busStops = getHelper().getBusStopDao().queryForAll();
- } else {
+ if (pastOverlays != null
+ && (uniLinkBusStopOverlay = (BusStopOverlay) pastOverlays
+ .get(UNI_LINK_BUS_STOP_OVERLAY)) != null) {
+ Log.i(TAG, "Restored Uni-Link bus stop overlay");
+ } else {
+
+ try {
+ List<BusStop> busStops;
+ Log.v(TAG, "Begin fetching BusStops at " + (System.currentTimeMillis() - startTime));
+
busStops = getHelper().getBusStopDao().queryForEq(BusStop.UNI_LINK_FIELD_NAME, true);
- }
- Log.v(TAG, "Finished fetching BusStops at " + (System.currentTimeMillis() - startTime));
- uniLinkBusStopOverlay = new BusStopOverlay(instance, busStops);
- } catch (SQLException e) {
- e.printStackTrace();
+ Log.v(TAG, "Finished fetching BusStops at " + (System.currentTimeMillis() - startTime));
+
+ uniLinkBusStopOverlay = new BusStopOverlay(instance, busStops);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
}
- }
- overlays.put(UNI_LINK_BUS_STOP_OVERLAY, uniLinkBusStopOverlay);
+ uniLinkBusStopOverlay.setRoutes(0, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(1, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(2, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(3, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(4, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
+ UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- Log.v(TAG, "Applyed the site overlay, now sorting them");
+ overlays.put(UNI_LINK_BUS_STOP_OVERLAY, uniLinkBusStopOverlay);
- synchronized (mapView.getOverlays()) {
- mapView.getOverlays().add(uniLinkBusStopOverlay);
- Collections.sort(mapView.getOverlays(), comparator);
+ Log.v(TAG, "Applyed the site overlay, now sorting them");
+
+ synchronized (mapView.getOverlays()) {
+ mapView.getOverlays().add(uniLinkBusStopOverlay);
+ Collections.sort(mapView.getOverlays(), comparator);
+ }
}
}
- uniLinkBusStopOverlay.setRoutes(0, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(1, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(2, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(3, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(4, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
-
mapView.postInvalidate();
Log.i(TAG, "Finished showing bus stop overlays at " + (System.currentTimeMillis() - startTime));
@@ -806,14 +837,23 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
Log.i(TAG, "Begining showing non uni link bus stop overlays at "
+ (System.currentTimeMillis() - startTime));
- final SharedPreferences activityPrefs = getPreferences(0);
+ // final SharedPreferences activityPrefs = getPreferences(0);
+ final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance);
final OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
- if (nonUniLinkBusStopOverlay == null
- && activityPrefs.getBoolean(NON_UNI_LINK_BUS_STOPS,
- NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
+ if (nonUniLinkBusStopOverlay != null) {
+ nonUniLinkBusStopOverlay.setEnabled(sharedPrefs.getBoolean(NON_UNI_LINK_BUS_STOPS_OVERLAY,
+ NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+
+ Log.i(TAG,
+ "nonUniLinkBusStopOverlay enabled ? "
+ + sharedPrefs.getBoolean(NON_UNI_LINK_BUS_STOPS_OVERLAY,
+ NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ } else if (sharedPrefs.getBoolean(NON_UNI_LINK_BUS_STOPS_OVERLAY,
+ NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
if (pastOverlays != null
- && (nonUniLinkBusStopOverlay = (BusStopOverlay) pastOverlays.get(NON_UNI_LINK_BUS_STOPS)) != null) {
+ && (nonUniLinkBusStopOverlay = (BusStopOverlay) pastOverlays
+ .get(NON_UNI_LINK_BUS_STOPS_OVERLAY)) != null) {
Log.i(TAG, "Restored non Uni-Link bus stop overlays");
} else {
try {
@@ -833,7 +873,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
}
- overlays.put(NON_UNI_LINK_BUS_STOP_OVERLAY, nonUniLinkBusStopOverlay);
+ overlays.put(NON_UNI_LINK_BUS_STOPS_OVERLAY, nonUniLinkBusStopOverlay);
Log.v(TAG, "Applyed the site overlay, now sorting them");
@@ -843,6 +883,10 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
}
+ if (nonUniLinkBusStopOverlay != null) {
+
+ }
+
mapView.postInvalidate();
Log.i(TAG, "Finished showing non Uni-Link bus stop overlays at "
@@ -1201,7 +1245,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
// Noting to do here atm
} else if (key.startsWith(BUS_STOP_OVERLAYS)) {
showUniLinkBusStopOverlay();
- } else if (key.equals(NON_UNI_LINK_BUS_STOPS)) {
+ } else if (key.equals(NON_UNI_LINK_BUS_STOPS_OVERLAY)) {
showNonUniLinkBusStopOverlay();
} else if (key.startsWith(BUS_ROUTE_OVERLAYS)) {
try {
diff --git a/src/net/cbaines/suma/Preferences.java b/src/net/cbaines/suma/Preferences.java
index d73d0ce..a978dd9 100644
--- a/src/net/cbaines/suma/Preferences.java
+++ b/src/net/cbaines/suma/Preferences.java
@@ -8,6 +8,6 @@ public interface Preferences {
static final boolean UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT = true;
static final String NON_UNI_LINK_BUS_TIMES = "nonUniLinkLiveBusTimesEnabled";
static final boolean NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT = false;
- static final String NON_UNI_LINK_BUS_STOPS = "nonUniLinkBusStops";
- static final boolean NON_UNI_LINK_BUS_STOPS_ENABLED_BY_DEFAULT = false;
+ static final String NON_UNI_LINK_BUS_STOPS_OVERLAY = "nonUniLinkBusStops";
+ static final boolean NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT = false;
}
diff --git a/src/net/cbaines/suma/PreferencesActivity.java b/src/net/cbaines/suma/PreferencesActivity.java
index 0d61c6d..d72d266 100644
--- a/src/net/cbaines/suma/PreferencesActivity.java
+++ b/src/net/cbaines/suma/PreferencesActivity.java
@@ -42,8 +42,8 @@ public class PreferencesActivity extends PreferenceActivity implements Preferenc
if (!sharedPrefs.contains(NON_UNI_LINK_BUS_TIMES)) {
editor.putBoolean(NON_UNI_LINK_BUS_TIMES, NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT);
}
- if (!sharedPrefs.contains(NON_UNI_LINK_BUS_STOPS)) {
- editor.putBoolean(NON_UNI_LINK_BUS_STOPS, NON_UNI_LINK_BUS_STOPS_ENABLED_BY_DEFAULT);
+ if (!sharedPrefs.contains(NON_UNI_LINK_BUS_STOPS_OVERLAY)) {
+ editor.putBoolean(NON_UNI_LINK_BUS_STOPS_OVERLAY, NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT);
}
editor.commit();