aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-28 14:01:42 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-28 14:01:42 +0000
commitb5d0db004eaf72e9eeff0dfd7f612591d670b139 (patch)
treee647c042998c3f51448ddd9c0b057dc95ef800f9 /src
parenta6dcb82b21325934ae3f4df9cfc5aad04d414653 (diff)
downloadsouthamptonuniversitymap-b5d0db004eaf72e9eeff0dfd7f612591d670b139.tar
southamptonuniversitymap-b5d0db004eaf72e9eeff0dfd7f612591d670b139.tar.gz
Added a BusRoute activity, and moved more stuff over to the new uri system.
Diffstat (limited to 'src')
-rw-r--r--src/net/cbaines/suma/BusRoute.java899
-rw-r--r--src/net/cbaines/suma/BusRouteActivity.java76
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java58
-rw-r--r--src/net/cbaines/suma/MapActivity.java180
-rw-r--r--src/net/cbaines/suma/POIArrayAdapter.java80
-rw-r--r--src/net/cbaines/suma/POIDialog.java86
-rw-r--r--src/net/cbaines/suma/POIView.java129
-rw-r--r--src/net/cbaines/suma/Waypoint.java42
8 files changed, 872 insertions, 678 deletions
diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java
index 4152605..b4dd603 100644
--- a/src/net/cbaines/suma/BusRoute.java
+++ b/src/net/cbaines/suma/BusRoute.java
@@ -45,456 +45,529 @@ import com.j256.ormlite.table.DatabaseTable;
@DatabaseTable(tableName = "busroutes")
public class BusRoute {
- private static final String TAG = "BusRoute";
-
- final static String ID_FIELD_NAME = "id";
- final static String CODE_FIELD_NAME = "code";
- final static String LABEL_FIELD_NAME = "label";
-
- @DatabaseField(id = true)
- public int id;
-
- /**
- * The route code (U1, U1N, ...)
- */
- @DatabaseField
- public String code;
-
- @DatabaseField(canBeNull = false)
- String label;
-
- /**
- * The direction the bus is travelling if it is moving through the route and sequence is increasing.
- * <ul>
- * <li>U1 = A</li>
- * <li>U2 = B</li>
- * <li>U6 = H</li>
- * </ul>
- */
- @DatabaseField(canBeNull = true)
- String forwardDirection;
-
- /**
- * The direction the bus is travelling if it is moving through the route and sequence is decreasing.
- * <ul>
- * <li>U1 = C</li>
- * <li>U2 = C</li>
- * <li>U6 = C</li>
- * </ul>
- */
- @DatabaseField(canBeNull = true)
- String reverseDirection;
-
- @DatabaseField(canBeNull = false)
- boolean uniLink;
-
- BusRoute() {
- }
-
- public BusRoute(Integer id, String code, String label, String forwardDirection, String reverseDirection,
- boolean uniLink) {
- this.id = id.intValue();
- this.code = code;
- this.label = label;
- this.forwardDirection = forwardDirection;
- this.reverseDirection = reverseDirection;
- this.uniLink = uniLink;
- }
-
- public BusRoute(Integer id, String code, String label, boolean uniLink) {
- this(id, code, label, null, null, uniLink);
- }
-
- public String toString() {
- return code;
- }
-
- /**
- * Untested?
- *
- * @param context
- * @param stop
- * @return
- */
- BusStop getBusStopBefore(Context context, BusStop stop, String dir) {
- return moveInRoute(context, stop, dir, -1);
- }
-
- /**
- * Untested?
- *
- * @param context
- * @param stop
- * @return
- */
- BusStop getStopAfter(Context context, BusStop stop, String dir) {
- return moveInRoute(context, stop, dir, 1);
- }
-
- /**
- * Untested?
- *
- * @param context
- * @param busStop
- * @param moveAmount
- * @return
- */
- Set<BusStop> moveInRoute(final Context context, final BusStop busStop, final int moveAmount) {
-
- Set<BusStop> busStops = new HashSet<BusStop>();
-
- if (moveAmount == 0) {
- busStops.add(busStop);
- return busStops;
+ private static final String TAG = "BusRoute";
+
+ final static String ID_FIELD_NAME = "id";
+ final static String CODE_FIELD_NAME = "code";
+ final static String LABEL_FIELD_NAME = "label";
+
+ @DatabaseField(id = true)
+ public int id;
+
+ /**
+ * The route code (U1, U1N, ...)
+ */
+ @DatabaseField
+ public String code;
+
+ @DatabaseField(canBeNull = false)
+ String label;
+
+ /**
+ * The direction the bus is travelling if it is moving through the route and
+ * sequence is increasing.
+ * <ul>
+ * <li>U1 = A</li>
+ * <li>U2 = B</li>
+ * <li>U6 = H</li>
+ * </ul>
+ */
+ @DatabaseField(canBeNull = true)
+ String forwardDirection;
+
+ /**
+ * The direction the bus is travelling if it is moving through the route and
+ * sequence is decreasing.
+ * <ul>
+ * <li>U1 = C</li>
+ * <li>U2 = C</li>
+ * <li>U6 = C</li>
+ * </ul>
+ */
+ @DatabaseField(canBeNull = true)
+ String reverseDirection;
+
+ @DatabaseField(canBeNull = false)
+ boolean uniLink;
+
+ BusRoute() {
}
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
+ public BusRoute(Integer id, String code, String label, String forwardDirection, String reverseDirection,
+ boolean uniLink) {
+ this.id = id.intValue();
+ this.code = code;
+ this.label = label;
+ this.forwardDirection = forwardDirection;
+ this.reverseDirection = reverseDirection;
+ this.uniLink = uniLink;
+ }
- try {
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
- Dao<BusStop, String> busStopDao = helper.getBusStopDao();
+ public BusRoute(Integer id, String code, String label, boolean uniLink) {
+ this(id, code, label, null, null, uniLink);
+ }
- QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
- routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
- PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+ public String toString() {
+ return code;
+ }
- List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ /**
+ * Untested?
+ *
+ * @param context
+ * @param stop
+ * @return
+ */
+ BusStop getBusStopBefore(Context context, BusStop stop, String dir) {
+ return moveInRoute(context, stop, dir, -1);
+ }
- ArrayList<Integer> stopIndexs = new ArrayList<Integer>();
+ /**
+ * Untested?
+ *
+ * @param context
+ * @param stop
+ * @return
+ */
+ BusStop getStopAfter(Context context, BusStop stop, String dir) {
+ return moveInRoute(context, stop, dir, 1);
+ }
- for (RouteStops routeStop : routeStopsFound) {
- if (routeStop.busStop.id.equals(busStop.id)) {
- stopIndexs.add(routeStop.sequence - 1);
- }
- }
-
- for (int stopIndex : stopIndexs) {
-
- if (moveAmount > 0) {
- Log.v(TAG, "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/"
- + routeStopsFound.size() + ")");
- int stopWanted = stopIndex + moveAmount;
- if ((stopWanted + 1) > routeStopsFound.size()) {
- Log.v(TAG, "Off the end of the route");
- stopWanted = stopWanted % (routeStopsFound.size() - 1);
- }
- Log.v(TAG, " Stop wanted " + stopWanted);
- BusStop busStopWanted = routeStopsFound.get(stopWanted).busStop;
-
- busStopDao.refresh(busStopWanted);
-
- Log.v(TAG, " Moving to " + busStopWanted + " (" + stopWanted + ") in route " + this);
-
- busStops.add(busStopWanted);
- } else {
- Log.v(TAG, "stopIndex " + stopIndex);
- int stopWanted = stopIndex + moveAmount;
- if (stopWanted < 0) {
- stopWanted = routeStopsFound.size() - (Math.abs(stopWanted) % routeStopsFound.size());
- }
- Log.v(TAG, "stopWanted " + stopWanted);
- busStopDao.refresh(routeStopsFound.get(stopWanted).busStop);
-
- Log.v(TAG,
- "Moving backwards " + moveAmount + " stops from " + busStop + " to "
- + routeStopsFound.get(stopWanted).busStop + " in route " + this);
-
- busStops.add(routeStopsFound.get(stopWanted).busStop);
+ /**
+ * Untested?
+ *
+ * @param context
+ * @param busStop
+ * @param moveAmount
+ * @return
+ */
+ Set<BusStop> moveInRoute(final Context context, final BusStop busStop, final int moveAmount) {
+
+ Set<BusStop> busStops = new HashSet<BusStop>();
+
+ if (moveAmount == 0) {
+ busStops.add(busStop);
+ return busStops;
}
- }
- return busStops;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- Log.e(TAG, "Error moving in route");
- return null;
- }
-
- /**
- * Untested?
- *
- * @param context
- * @param busStop
- * @param moveAmount
- * @return
- */
- BusStop moveInRoute(final Context context, final BusStop busStop, String direction, final int moveAmount) {
-
- if (moveAmount == 0) {
- return busStop;
- }
+ DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
+
+ try {
+ Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<BusStop, String> busStopDao = helper.getBusStopDao();
+
+ QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
+ PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
+ List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
- if (forwardDirection != null) {
+ ArrayList<Integer> stopIndexs = new ArrayList<Integer>();
- if (direction != null) {
+ for (RouteStops routeStop : routeStopsFound) {
+ if (routeStop.busStop.id.equals(busStop.id)) {
+ stopIndexs.add(routeStop.sequence - 1);
+ }
+ }
+
+ for (int stopIndex : stopIndexs) {
+
+ if (moveAmount > 0) {
+ Log.v(TAG, "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/"
+ + routeStopsFound.size() + ")");
+ int stopWanted = stopIndex + moveAmount;
+ if ((stopWanted + 1) > routeStopsFound.size()) {
+ Log.v(TAG, "Off the end of the route");
+ stopWanted = stopWanted % (routeStopsFound.size() - 1);
+ }
+ Log.v(TAG, " Stop wanted " + stopWanted);
+ BusStop busStopWanted = routeStopsFound.get(stopWanted).busStop;
+
+ busStopDao.refresh(busStopWanted);
+
+ Log.v(TAG, " Moving to " + busStopWanted + " (" + stopWanted + ") in route " + this);
+
+ busStops.add(busStopWanted);
+ } else {
+ Log.v(TAG, "stopIndex " + stopIndex);
+ int stopWanted = stopIndex + moveAmount;
+ if (stopWanted < 0) {
+ stopWanted = routeStopsFound.size() - (Math.abs(stopWanted) % routeStopsFound.size());
+ }
+ Log.v(TAG, "stopWanted " + stopWanted);
+ busStopDao.refresh(routeStopsFound.get(stopWanted).busStop);
+
+ Log.v(TAG,
+ "Moving backwards " + moveAmount + " stops from " + busStop + " to "
+ + routeStopsFound.get(stopWanted).busStop + " in route " + this);
+
+ busStops.add(routeStopsFound.get(stopWanted).busStop);
+ }
+ }
- if (direction.equals("E"))
- direction = "A"; // Quick hack for U1E
- } else {
- throw new NullPointerException("direction is null");
- }
+ return busStops;
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ Log.e(TAG, "Error moving in route");
+ return null;
}
- try {
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
- Dao<BusStop, String> busStopDao = helper.getBusStopDao();
-
- QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
- routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
- PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
-
- List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
-
- int stopIndex = -1;
-
- for (RouteStops routeStop : routeStopsFound) {
- if (routeStop.busStop.id.equals(busStop.id)) {
- if (stopIndex == -1) {
- stopIndex = routeStop.sequence - 1;
- } else { // ARGH, weird route
- if (busStop.id.equals("HAA13651") && id == 327) { // U6 by Wessex Lane
- if (direction.equals(forwardDirection)) {
- stopIndex = 23;
- } else {
- stopIndex = 68;
- }
- } else if (busStop.id.equals("SN120134") && id == 327) { // U6 opposite the Stile
- if (direction.equals(forwardDirection)) {
- stopIndex = 30;
- } else {
- stopIndex = 59;
- }
- } else if (busStop.id.equals("SN120163") && id == 327) { // U6 just up past wessex lane
- if (direction.equals(forwardDirection)) {
- stopIndex = 22;
- } else {
- stopIndex = 67;
- }
- } else if (busStop.id.equals("SNA19482") && id == 327) { // U6 General Hosp West Door
- if (moveAmount > 0) {
- stopIndex = 44;
- } else {
- stopIndex = 43;
- }
- } else if (busStop.id.equals("SN120134") && id == 329) { // U2 opposite the Stile
- if (direction.equals(forwardDirection)) {
- stopIndex = 13;
- } else {
- stopIndex = 30;
- }
- } else if (busStop.id.equals("SN120527") && id == 329) { // U2 Civic Centre Rd os stop AO Civic
- // Ctr E
- if (moveAmount > 0) {
- stopIndex = 0;
- } else {
- stopIndex = 42;
- }
- } else if (busStop.id.equals("SNA09298") && id == 329) { // U2 Bassett Green Rd nr Bassett Green
- // Cl SE
- if (moveAmount > 0) {
- stopIndex = 22;
- } else {
- stopIndex = 21;
- }
- } else if (busStop.id.equals("SN120520") && id == 326) { // U1 By the station
- if (direction.equals(forwardDirection)) {
- stopIndex = 7;
- } else {
- stopIndex = 80;
- }
- } else if (busStop.id.equals("HA030183") && id == 326) { // U1 Up past Wessex Lane
- if (direction.equals(forwardDirection)) {
- stopIndex = 35;
- } else {
- stopIndex = 50;
- }
- } else if (busStop.id.equals("HA030212") && id == 326) { // U1 At Eastleigh
- if (moveAmount > 0) {
- stopIndex = 43;
- } else {
- stopIndex = 42;
- }
- } else if (busStop.id.equals("SN120171") && id == 354) { // U9
- if (moveAmount > 0) {
- stopIndex = 0;
- } else {
- stopIndex = 73;
- }
+ /**
+ * Untested?
+ *
+ * @param context
+ * @param busStop
+ * @param moveAmount
+ * @return
+ */
+ BusStop moveInRoute(final Context context, final BusStop busStop, String direction, final int moveAmount) {
+
+ if (moveAmount == 0) {
+ return busStop;
+ }
+
+ DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
+
+ if (forwardDirection != null) {
+
+ if (direction != null) {
+
+ if (direction.equals("E"))
+ direction = "A"; // Quick hack for U1E
} else {
- Log.e(TAG, "Error, unknown bus stop " + busStop.id + " (" + busStop.description
- + ") that appears mutiple times in " + toString());
- throw new RuntimeException("Error, unknown bus stop " + busStop.id
- + " that appears mutiple times in " + toString());
+ throw new NullPointerException("direction is null");
}
- Log.v(TAG, "Selecting " + stopIndex + " for " + busStop.id + " as direction == " + direction);
- }
}
- }
-
- if (moveAmount > 0) {
- Log.v(TAG, "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/"
- + routeStopsFound.size() + ")");
- int stopWanted = stopIndex + moveAmount;
- if ((stopWanted + 1) > routeStopsFound.size()) {
- Log.v(TAG, "Off the end of the route");
- stopWanted = stopWanted % (routeStopsFound.size() - 1);
+
+ try {
+ Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<BusStop, String> busStopDao = helper.getBusStopDao();
+
+ QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
+ PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+
+ List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+
+ int stopIndex = -1;
+
+ for (RouteStops routeStop : routeStopsFound) {
+ if (routeStop.busStop.id.equals(busStop.id)) {
+ if (stopIndex == -1) {
+ stopIndex = routeStop.sequence - 1;
+ } else { // ARGH, weird route
+ if (busStop.id.equals("HAA13651") && id == 327) { // U6
+ // by
+ // Wessex
+ // Lane
+ if (direction.equals(forwardDirection)) {
+ stopIndex = 23;
+ } else {
+ stopIndex = 68;
+ }
+ } else if (busStop.id.equals("SN120134") && id == 327) { // U6
+ // opposite
+ // the
+ // Stile
+ if (direction.equals(forwardDirection)) {
+ stopIndex = 30;
+ } else {
+ stopIndex = 59;
+ }
+ } else if (busStop.id.equals("SN120163") && id == 327) { // U6
+ // just
+ // up
+ // past
+ // wessex
+ // lane
+ if (direction.equals(forwardDirection)) {
+ stopIndex = 22;
+ } else {
+ stopIndex = 67;
+ }
+ } else if (busStop.id.equals("SNA19482") && id == 327) { // U6
+ // General
+ // Hosp
+ // West
+ // Door
+ if (moveAmount > 0) {
+ stopIndex = 44;
+ } else {
+ stopIndex = 43;
+ }
+ } else if (busStop.id.equals("SN120134") && id == 329) { // U2
+ // opposite
+ // the
+ // Stile
+ if (direction.equals(forwardDirection)) {
+ stopIndex = 13;
+ } else {
+ stopIndex = 30;
+ }
+ } else if (busStop.id.equals("SN120527") && id == 329) { // U2
+ // Civic
+ // Centre
+ // Rd
+ // os
+ // stop
+ // AO
+ // Civic
+ // Ctr E
+ if (moveAmount > 0) {
+ stopIndex = 0;
+ } else {
+ stopIndex = 42;
+ }
+ } else if (busStop.id.equals("SNA09298") && id == 329) { // U2
+ // Bassett
+ // Green
+ // Rd
+ // nr
+ // Bassett
+ // Green
+ // Cl SE
+ if (moveAmount > 0) {
+ stopIndex = 22;
+ } else {
+ stopIndex = 21;
+ }
+ } else if (busStop.id.equals("SN120520") && id == 326) { // U1
+ // By
+ // the
+ // station
+ if (direction.equals(forwardDirection)) {
+ stopIndex = 7;
+ } else {
+ stopIndex = 80;
+ }
+ } else if (busStop.id.equals("HA030183") && id == 326) { // U1
+ // Up
+ // past
+ // Wessex
+ // Lane
+ if (direction.equals(forwardDirection)) {
+ stopIndex = 35;
+ } else {
+ stopIndex = 50;
+ }
+ } else if (busStop.id.equals("HA030212") && id == 326) { // U1
+ // At
+ // Eastleigh
+ if (moveAmount > 0) {
+ stopIndex = 43;
+ } else {
+ stopIndex = 42;
+ }
+ } else if (busStop.id.equals("SN120171") && id == 354) { // U9
+ if (moveAmount > 0) {
+ stopIndex = 0;
+ } else {
+ stopIndex = 73;
+ }
+ } else {
+ Log.e(TAG, "Error, unknown bus stop " + busStop.id + " (" + busStop.description
+ + ") that appears mutiple times in " + toString());
+ throw new RuntimeException("Error, unknown bus stop " + busStop.id
+ + " that appears mutiple times in " + toString());
+ }
+ Log.v(TAG, "Selecting " + stopIndex + " for " + busStop.id + " as direction == " + direction);
+ }
+ }
+ }
+
+ if (moveAmount > 0) {
+ Log.v(TAG, "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/"
+ + routeStopsFound.size() + ")");
+ int stopWanted = stopIndex + moveAmount;
+ if ((stopWanted + 1) > routeStopsFound.size()) {
+ Log.v(TAG, "Off the end of the route");
+ stopWanted = stopWanted % (routeStopsFound.size() - 1);
+ }
+ Log.v(TAG, " Stop wanted " + stopWanted);
+ BusStop busStopWanted = routeStopsFound.get(stopWanted).busStop;
+
+ busStopDao.refresh(busStopWanted);
+
+ Log.v(TAG, " Moving to " + busStopWanted + " (" + stopWanted + ") in route " + this);
+
+ return busStopWanted;
+ } else {
+ Log.v(TAG, "stopIndex " + stopIndex);
+ int stopWanted = stopIndex + moveAmount;
+ if (stopWanted < 0) {
+ stopWanted = routeStopsFound.size() - (Math.abs(stopWanted) % routeStopsFound.size());
+ }
+ Log.v(TAG, "stopWanted " + stopWanted);
+ busStopDao.refresh(routeStopsFound.get(stopWanted).busStop);
+
+ Log.v(TAG,
+ "Moving backwards " + moveAmount + " stops from " + busStop + " to "
+ + routeStopsFound.get(stopWanted).busStop + " in route " + this);
+
+ return routeStopsFound.get(stopWanted).busStop;
+ }
+
+ } catch (SQLException e) {
+ e.printStackTrace();
}
- Log.v(TAG, " Stop wanted " + stopWanted);
- BusStop busStopWanted = routeStopsFound.get(stopWanted).busStop;
+ Log.e(TAG, "Error moving in route");
+ return null;
+ }
- busStopDao.refresh(busStopWanted);
+ /**
+ * Untested?
+ *
+ * @param context
+ * @param busStop
+ * @param moveAmount
+ * @return
+ */
+ List<BusStop> getRouteSection(final Context context, String direction) {
- Log.v(TAG, " Moving to " + busStopWanted + " (" + stopWanted + ") in route " + this);
+ DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
- return busStopWanted;
- } else {
- Log.v(TAG, "stopIndex " + stopIndex);
- int stopWanted = stopIndex + moveAmount;
- if (stopWanted < 0) {
- stopWanted = routeStopsFound.size() - (Math.abs(stopWanted) % routeStopsFound.size());
+ if (forwardDirection != null) {
+
+ if (direction != null) {
+
+ if (direction.equals("E"))
+ direction = "A"; // Quick hack for U1E
+ } else {
+ throw new NullPointerException("direction is null");
+ }
}
- Log.v(TAG, "stopWanted " + stopWanted);
- busStopDao.refresh(routeStopsFound.get(stopWanted).busStop);
- Log.v(TAG,
- "Moving backwards " + moveAmount + " stops from " + busStop + " to "
- + routeStopsFound.get(stopWanted).busStop + " in route " + this);
+ List<BusStop> busStops = new ArrayList<BusStop>();
+
+ try {
+
+ Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<BusStop, String> busStopDao = helper.getBusStopDao();
+
+ QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
+ PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+
+ List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+
+ int startStopSeq = -1;
+ int endStopSeq = -1;
+
+ if (id == 326) { // U1
+ if (direction.equals(forwardDirection)) {
+ startStopSeq = 1;
+ endStopSeq = 43;
+ } else if (direction.equals(reverseDirection)) {
+ startStopSeq = 44;
+ endStopSeq = 88;
+ } else {
+ Log.e(TAG, "Error, unrecognised direction " + direction);
+ }
+ } else if (id == 468) { // U1N
+ startStopSeq = 1;
+ endStopSeq = 29;
+ } else if (id == 329) { // U2
+ if (direction.equals(forwardDirection)) {
+ startStopSeq = 1;
+ endStopSeq = 22;
+ } else if (direction.equals(reverseDirection)) {
+ startStopSeq = 23;
+ endStopSeq = 43;
+ } else {
+ Log.e(TAG, "Error, unrecognised direction " + direction);
+ }
+ } else if (id == 327) { // U6
+ if (direction.equals(forwardDirection)) {
+ startStopSeq = 1;
+ endStopSeq = 44;
+ } else if (direction.equals(reverseDirection)) {
+ startStopSeq = 45;
+ endStopSeq = 93;
+ } else {
+ Log.e(TAG, "Error, unrecognised direction " + direction);
+ }
+ } else if (id == 354) { // U9
+ Calendar rightNow = Calendar.getInstance();
+ if (rightNow.get(Calendar.HOUR_OF_DAY) < 12) {
+ startStopSeq = 1;
+ endStopSeq = 40; // TODO: Guess, and untested
+ } else {
+ startStopSeq = 41; // TODO: Guess, and untested
+ endStopSeq = 74;
+ }
+ } else {
+ Log.e(TAG, "Error, unrecognised route " + id);
+ }
+
+ for (RouteStops routeStop : routeStopsFound) {
+ if (routeStop.sequence >= startStopSeq && routeStop.sequence <= endStopSeq) {
+ busStopDao.refresh(routeStop.busStop);
+ busStops.add(routeStop.busStop);
+ }
+ }
- return routeStopsFound.get(stopWanted).busStop;
- }
+ return busStops;
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ Log.e(TAG, "Error moving in route");
+ return null;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- Log.e(TAG, "Error moving in route");
- return null;
- }
-
- /**
- * Untested?
- *
- * @param context
- * @param busStop
- * @param moveAmount
- * @return
- */
- List<BusStop> getRouteSection(final Context context, String direction) {
-
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
-
- if (forwardDirection != null) {
-
- if (direction != null) {
-
- if (direction.equals("E"))
- direction = "A"; // Quick hack for U1E
- } else {
- throw new NullPointerException("direction is null");
- }
}
- List<BusStop> busStops = new ArrayList<BusStop>();
+ List<BusStop> getRouteBusStops(final Context context) {
- try {
+ DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
- Dao<BusStop, String> busStopDao = helper.getBusStopDao();
+ List<BusStop> busStops = new ArrayList<BusStop>();
- QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
- routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
- PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+ try {
- List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<BusStop, String> busStopDao = helper.getBusStopDao();
- int startStopSeq = -1;
- int endStopSeq = -1;
+ QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
+ PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
- if (id == 326) { // U1
- if (direction.equals(forwardDirection)) {
- startStopSeq = 1;
- endStopSeq = 43;
- } else if (direction.equals(reverseDirection)) {
- startStopSeq = 44;
- endStopSeq = 88;
- } else {
- Log.e(TAG, "Error, unrecognised direction " + direction);
- }
- } else if (id == 468) { // U1N
- startStopSeq = 1;
- endStopSeq = 29;
- } else if (id == 329) { // U2
- if (direction.equals(forwardDirection)) {
- startStopSeq = 1;
- endStopSeq = 22;
- } else if (direction.equals(reverseDirection)) {
- startStopSeq = 23;
- endStopSeq = 43;
- } else {
- Log.e(TAG, "Error, unrecognised direction " + direction);
- }
- } else if (id == 327) { // U6
- if (direction.equals(forwardDirection)) {
- startStopSeq = 1;
- endStopSeq = 44;
- } else if (direction.equals(reverseDirection)) {
- startStopSeq = 45;
- endStopSeq = 93;
- } else {
- Log.e(TAG, "Error, unrecognised direction " + direction);
- }
- } else if (id == 354) { // U9
- Calendar rightNow = Calendar.getInstance();
- if (rightNow.get(Calendar.HOUR_OF_DAY) < 12) {
- startStopSeq = 1;
- endStopSeq = 40; // TODO: Guess, and untested
- } else {
- startStopSeq = 41; // TODO: Guess, and untested
- endStopSeq = 74;
- }
- } else {
- Log.e(TAG, "Error, unrecognised route " + id);
- }
-
- for (RouteStops routeStop : routeStopsFound) {
- if (routeStop.sequence >= startStopSeq && routeStop.sequence <= endStopSeq) {
- busStopDao.refresh(routeStop.busStop);
- busStops.add(routeStop.busStop);
+ List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+
+ for (RouteStops routeStop : routeStopsFound) {
+ busStopDao.refresh(routeStop.busStop);
+ busStops.add(routeStop.busStop);
+ }
+
+ return busStops;
+ } catch (SQLException e) {
+ e.printStackTrace();
}
- }
+ Log.e(TAG, "Error moving in route");
+ return null;
- return busStops;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + id;
+ return result;
+ }
- } catch (SQLException e) {
- e.printStackTrace();
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BusRoute other = (BusRoute) obj;
+ if (id != other.id)
+ return false;
+ return true;
}
- Log.e(TAG, "Error moving in route");
- return null;
-
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + id;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- BusRoute other = (BusRoute) obj;
- if (id != other.id)
- return false;
- return true;
- }
}
diff --git a/src/net/cbaines/suma/BusRouteActivity.java b/src/net/cbaines/suma/BusRouteActivity.java
new file mode 100644
index 0000000..3670c68
--- /dev/null
+++ b/src/net/cbaines/suma/BusRouteActivity.java
@@ -0,0 +1,76 @@
+package net.cbaines.suma;
+
+import java.sql.SQLException;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
+
+public class BusRouteActivity extends OrmLiteBaseActivity<DatabaseHelper> implements Preferences {
+ final static String TAG = "BusActivity";
+
+ private TextView busRouteLabel;
+ private TextView busRouteCode;
+ private TextView busRouteID;
+
+ Toast activityToast;
+
+ private ListView busRouteView;
+
+ private Context instance;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.bus_route_activity);
+ instance = this;
+
+ Log.i(TAG, "getIntent().getDataString() " + getIntent().getDataString());
+
+ String strBusRouteID;
+
+ if (getIntent().getDataString().startsWith("http://data")) {
+
+ String[] uriParts = getIntent().getDataString().split("/");
+
+ strBusRouteID = uriParts[uriParts.length - 1].replace(".html", "");
+
+ } else {
+
+ String[] uriParts = getIntent().getDataString().split("/");
+
+ strBusRouteID = uriParts[uriParts.length - 1];
+ }
+
+ final DatabaseHelper helper = getHelper();
+
+ BusRoute busRoute = null;
+
+ try {
+ busRoute = helper.getBusRouteDao().queryForId(Integer.parseInt(strBusRouteID));
+
+ busRouteLabel = (TextView) findViewById(R.id.busRouteActivityLabel);
+ busRouteLabel.setText(busRoute.label);
+
+ busRouteCode = (TextView) findViewById(R.id.busRouteActivityCode);
+ busRouteCode.setText(busRoute.code);
+
+ busRouteID = (TextView) findViewById(R.id.busRouteActivityID);
+ busRouteID.setText(String.valueOf(busRoute.id));
+
+ busRouteView = (ListView) findViewById(R.id.busRouteBusStops);
+
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ POIArrayAdapter arrayAdapter = new POIArrayAdapter(instance, busRoute.getRouteBusStops(instance));
+ busRouteView.setAdapter(arrayAdapter);
+ }
+}
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index dbed3ee..62a0f54 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -33,6 +33,7 @@ import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@@ -43,6 +44,7 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.View.OnLongClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox;
@@ -59,8 +61,8 @@ import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
-public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OnCheckedChangeListener, Preferences,
- OnItemClickListener {
+public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OnCheckedChangeListener,
+ Preferences, OnItemClickListener, OnLongClickListener {
final static String TAG = "BusTimeActivity";
@@ -133,10 +135,19 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
U9RouteRadioButton = (CheckBox) findViewById(R.id.radio_u9);
U1RouteRadioButton.setOnCheckedChangeListener(this);
+ U1RouteRadioButton.setOnLongClickListener(this);
+
U1NRouteRadioButton.setOnCheckedChangeListener(this);
+ U1NRouteRadioButton.setOnLongClickListener(this);
+
U2RouteRadioButton.setOnCheckedChangeListener(this);
+ U2RouteRadioButton.setOnLongClickListener(this);
+
U6RouteRadioButton.setOnCheckedChangeListener(this);
+ U6RouteRadioButton.setOnLongClickListener(this);
+
U9RouteRadioButton.setOnCheckedChangeListener(this);
+ U9RouteRadioButton.setOnLongClickListener(this);
try {
Dao<BusStop, String> busStopDao = helper.getBusStopDao();
@@ -310,10 +321,10 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
try {
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance);
- newTimetable = DataManager
- .getTimetable(instance, busStop.id, sharedPrefs.getBoolean(MapActivity.UNI_LINK_BUS_TIMES,
- MapActivity.UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT), sharedPrefs.getBoolean(
- MapActivity.NON_UNI_LINK_BUS_TIMES, MapActivity.NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT));
+ newTimetable = DataManager.getTimetable(instance, busStop.id, sharedPrefs.getBoolean(
+ MapActivity.UNI_LINK_BUS_TIMES, MapActivity.UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT), sharedPrefs
+ .getBoolean(MapActivity.NON_UNI_LINK_BUS_TIMES,
+ MapActivity.NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT));
} catch (SQLException e) {
errorMessage = "Error message regarding SQL?";
e.printStackTrace();
@@ -387,7 +398,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
Log.i(TAG, "stops " + busStops);
if (busStops.size() == 1) {
- Intent i = new Intent(this, BusStopActivity.class);
+
BusStop stop = (BusStop) busStops.iterator().next();
if (stop == null) {
Log.e(TAG, "stop == null");
@@ -395,9 +406,14 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
if (stop.id == null) {
Log.e(TAG, "stop.id == null");
}
- i.putExtra("busStopID", stop.id);
- i.putExtra("busStopName", stop.description);
- startActivity(i);
+
+ Uri uri = Uri.parse("http://id.southampton.ac.uk/bus-stop/" + busStop.id);
+
+ Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath());
+
+ Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(busStopIntent);
+
} else {
showDialog(POI_DIALOG_ID);
if (busDialog == null) {
@@ -522,4 +538,26 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
}
}
+
+ public boolean onLongClick(View v) {
+ Uri uri = null;
+ if (v.equals(U1RouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/326");
+ } else if (v.equals(U1NRouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/468");
+ } else if (v.equals(U2RouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/329");
+ } else if (v.equals(U6RouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/327");
+ } else if (v.equals(U9RouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/354");
+ }
+ if (uri != null) {
+ Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath());
+
+ Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(busStopIntent);
+ }
+ return false;
+ }
}
diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java
index 07806fa..59c8505 100644
--- a/src/net/cbaines/suma/MapActivity.java
+++ b/src/net/cbaines/suma/MapActivity.java
@@ -50,6 +50,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
+import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
@@ -70,12 +71,13 @@ import com.j256.ormlite.dao.Dao;
* @author Christopher Baines <cbaines8@gmail.com>
*
*/
-public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements MapViewConstants, Runnable, RouteColorConstants,
- OnItemClickListener, OnItemLongClickListener, OnSharedPreferenceChangeListener, Preferences {
+public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements MapViewConstants, Runnable,
+ RouteColorConstants, OnItemClickListener, OnItemLongClickListener, OnSharedPreferenceChangeListener,
+ 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
+ * 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 = true;
@@ -125,10 +127,11 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
private static final int NON_UNI_LINK_BUS_STOP_OVERLAY_RANK = 4;
// -- Site Overlays
- static final String[] SITE_NAMES = { "Highfield Campus", "Boldrewood Campus", "Avenue Campus", "Winchester School of Art",
- "The University of Southampton Science Park", "National Oceanography Centre Campus", "Boat House",
- "Southampton General Hospital", "Royal South Hants Hospital", "Belgrave Industrial Site", "Highfield Hall",
- "Glen Eyre Hall", "South Hill Hall", "Chamberlain Hall", "Hartley Grove", "Bencraft Hall", "Connaught Hall",
+ static final String[] SITE_NAMES = { "Highfield Campus", "Boldrewood Campus", "Avenue Campus",
+ "Winchester School of Art", "The University of Southampton Science Park",
+ "National Oceanography Centre Campus", "Boat House", "Southampton General Hospital",
+ "Royal South Hants Hospital", "Belgrave Industrial Site", "Highfield Hall", "Glen Eyre Hall",
+ "South Hill Hall", "Chamberlain Hall", "Hartley Grove", "Bencraft Hall", "Connaught Hall",
"Montefiore Hall", "Stoneham Hall", "Erasmus Park" };
private static final String SITE_OVERLAYS = "siteOverlays:";
@@ -166,14 +169,15 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
// Uni-Link routes
static final String[] UNI_LINK_ROUTES = { "U1", "U1N", "U2", "U6", "U9" };
- static final String[] PREFERENCES_GROUPS = { BUS_STOP_OVERLAYS, BUS_ROUTE_OVERLAYS, BUILDING_OVERLAYS, SITE_OVERLAYS,
- OTHER_OVERLAYS };
+ static final String[] PREFERENCES_GROUPS = { BUS_STOP_OVERLAYS, BUS_ROUTE_OVERLAYS, BUILDING_OVERLAYS,
+ SITE_OVERLAYS, OTHER_OVERLAYS };
static final String[][] PREFERENCES_CHILDREN = { UNI_LINK_ROUTES, UNI_LINK_ROUTES, BUILDING_TYPES, SITE_NAMES,
OTHER_OVERLAY_NAMES };
/**
- * The toast for this activity, storing the toast centrally allows it to be changed quickly, instead of a queue building up
+ * The toast for this activity, storing the toast centrally allows it to be
+ * changed quickly, instead of a queue building up
*/
Toast activityToast;
@@ -204,8 +208,10 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
pastOverlays = (HashMap<String, Overlay>) getLastNonConfigurationInstance();
/*
- * SensorManager mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); This code in the following
- * constructor causes problems in some emulators, disable sensors to fix.
+ * SensorManager mSensorManager = (SensorManager)
+ * getSystemService(Context.SENSOR_SERVICE); This code in the following
+ * constructor causes problems in some emulators, disable sensors to
+ * fix.
*/
Log.i(TAG, "Starting creating myLocationOverlay");
myLocationOverlay = new MyLocationOverlay(instance, mapView);
@@ -494,7 +500,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
if (scaleBarOverlay != null) {
Log.v(TAG, "ScaleBarOverlay is already created");
} else {
- if (pastOverlays != null && (scaleBarOverlay = (ScaleBarOverlay) pastOverlays.get(SCALE_BAR_OVERLAY)) != null) {
+ if (pastOverlays != null
+ && (scaleBarOverlay = (ScaleBarOverlay) pastOverlays.get(SCALE_BAR_OVERLAY)) != null) {
Log.i(TAG, "Finished restoring utility overlays " + (System.currentTimeMillis() - startTime));
} else {
scaleBarOverlay = new ScaleBarOverlay(instance);
@@ -523,7 +530,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
private void showRouteOverlay(final BusRoute route) {
new Thread(new Runnable() {
public void run() {
- Log.i(TAG, "Begining showing route " + route.code + " overlay at " + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Begining showing route " + route.code + " overlay at "
+ + (System.currentTimeMillis() - startTime));
final SharedPreferences activityPrefs = getPreferences(0);
final OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
@@ -548,8 +556,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
// 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);
+ PathOverlay routeOverlayU1E = DataManager.getRoutePath(
+ getResources().openRawResource(R.raw.u1e), colour, mResourceProxy);
routeOverlayU1E.getPaint().setAntiAlias(true);
routeOverlayU1E.getPaint().setAlpha(145);
routeOverlayU1E.getPaint().setStrokeWidth(12);
@@ -604,7 +612,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
mapView.postInvalidate();
- Log.i(TAG, "Finished showing route " + route.code + " overlay at " + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Finished showing route " + route.code + " overlay at "
+ + (System.currentTimeMillis() - startTime));
}
}).start();
}
@@ -613,7 +622,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
new Thread(new Runnable() {
public void run() {
- Log.i(TAG, "Begining showing site " + site.name + " overlay at " + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Begining showing site " + site.name + " overlay at "
+ + (System.currentTimeMillis() - startTime));
final SharedPreferences activityPrefs = getPreferences(0);
final OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
@@ -622,7 +632,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
if ((siteOverlay = siteOverlays.get(site)) != null) {
} else {
- if (pastOverlays != null && (siteOverlay = (PathOverlay) pastOverlays.get(SITE_OVERLAYS + site.name)) != null) {
+ if (pastOverlays != null
+ && (siteOverlay = (PathOverlay) pastOverlays.get(SITE_OVERLAYS + site.name)) != null) {
Log.i(TAG, "Restored " + site.name + " site overlay");
} else {
@@ -648,11 +659,13 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
}
- siteOverlay.setEnabled(activityPrefs.getBoolean(SITE_OVERLAYS + site.name, SITE_OVERLAYS_ENABLED_BY_DEFAULT));
+ siteOverlay.setEnabled(activityPrefs.getBoolean(SITE_OVERLAYS + site.name,
+ SITE_OVERLAYS_ENABLED_BY_DEFAULT));
mapView.postInvalidate();
- Log.i(TAG, "Finished showing site " + site.name + " overlay at " + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Finished showing site " + site.name + " overlay at "
+ + (System.currentTimeMillis() - startTime));
}
}).start();
}
@@ -669,8 +682,10 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
} else {
if (pastOverlays != null
- && (residentialBuildingOverlay = (BuildingNumOverlay) pastOverlays.get(RESIDENTIAL_BUILDING_OVERLAY)) != null) {
- nonResidentialBuildingOverlay = (BuildingNumOverlay) pastOverlays.get(NON_RESIDENTIAL_BUILDING_OVERLAY);
+ && (residentialBuildingOverlay = (BuildingNumOverlay) pastOverlays
+ .get(RESIDENTIAL_BUILDING_OVERLAY)) != null) {
+ nonResidentialBuildingOverlay = (BuildingNumOverlay) pastOverlays
+ .get(NON_RESIDENTIAL_BUILDING_OVERLAY);
Log.i(TAG, "Restored building overlays");
} else {
@@ -685,7 +700,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
buildingDao = getHelper().getBuildingDao();
- final SharedPreferences favouritesPrefs = getSharedPreferences(FAVOURITES_PREFERENCES, MODE_PRIVATE);
+ final SharedPreferences favouritesPrefs = getSharedPreferences(FAVOURITES_PREFERENCES,
+ MODE_PRIVATE);
for (Building building : buildingDao) {
if (building.residential == true) {
@@ -723,8 +739,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
}
- residentialBuildingOverlay.setEnabled(activityPrefs.getBoolean(BUILDING_OVERLAYS + RESIDENTIAL_BUILDING_OVERLAY,
- RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT));
+ residentialBuildingOverlay.setEnabled(activityPrefs.getBoolean(BUILDING_OVERLAYS
+ + RESIDENTIAL_BUILDING_OVERLAY, RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT));
nonResidentialBuildingOverlay.setEnabled(activityPrefs.getBoolean(BUILDING_OVERLAYS
+ NON_RESIDENTIAL_BUILDING_OVERLAY, NON_RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT));
@@ -744,11 +760,16 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
final OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
if (uniLinkBusStopOverlay != null) {
- 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)) {
+ 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");
overlays.remove(UNI_LINK_BUS_STOP_OVERLAY);
@@ -759,25 +780,31 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
uniLinkBusStopOverlay = null;
} else {
- 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));
+ 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)) {
+ 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)) {
if (pastOverlays != null
- && (uniLinkBusStopOverlay = (BusStopOverlay) pastOverlays.get(UNI_LINK_BUS_STOP_OVERLAY)) != null) {
+ && (uniLinkBusStopOverlay = (BusStopOverlay) pastOverlays
+ .get(UNI_LINK_BUS_STOP_OVERLAY)) != null) {
Log.i(TAG, "Restored Uni-Link bus stop overlay");
} else {
@@ -795,16 +822,16 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
}
- 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));
+ 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));
overlays.put(UNI_LINK_BUS_STOP_OVERLAY, uniLinkBusStopOverlay);
@@ -827,7 +854,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
private void showNonUniLinkBusStopOverlay() {
new Thread(new Runnable() {
public void run() {
- Log.i(TAG, "Begining showing non uni link bus stop overlays at " + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Begining showing non uni link bus stop overlays at "
+ + (System.currentTimeMillis() - startTime));
// final SharedPreferences activityPrefs = getPreferences(0);
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance);
@@ -844,12 +872,14 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
} 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_OVERLAY)) != null) {
+ && (nonUniLinkBusStopOverlay = (BusStopOverlay) pastOverlays
+ .get(NON_UNI_LINK_BUS_STOPS_OVERLAY)) != null) {
Log.i(TAG, "Restored non Uni-Link bus stop overlays");
} else {
try {
List<BusStop> busStops;
- Log.v(TAG, "Begin fetching non Uni-Link BusStops at " + (System.currentTimeMillis() - startTime));
+ Log.v(TAG, "Begin fetching non Uni-Link BusStops at "
+ + (System.currentTimeMillis() - startTime));
busStops = getHelper().getBusStopDao().queryForEq(BusStop.UNI_LINK_FIELD_NAME, false);
@@ -879,7 +909,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
mapView.postInvalidate();
- Log.i(TAG, "Finished showing non Uni-Link bus stop overlays at " + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Finished showing non Uni-Link bus stop overlays at "
+ + (System.currentTimeMillis() - startTime));
}
}).start();
}
@@ -941,8 +972,9 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage("GPS is not enabled, do you wish to enable it?").setPositiveButton("Yes", dialogClickListener)
- .setNegativeButton("No", dialogClickListener).show();
+ builder.setMessage("GPS is not enabled, do you wish to enable it?")
+ .setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener)
+ .show();
}
return true;
@@ -1060,9 +1092,11 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
/*
- * public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
+ * public boolean onChildClick(ExpandableListView parent, View v, int
+ * groupPosition, int childPosition, long id) {
*
- * mapView.post(new Runnable() { public void run() { // updateEnabledOverlays(); TODO Fix whatever this did?
+ * mapView.post(new Runnable() { public void run() { //
+ * updateEnabledOverlays(); TODO Fix whatever this did?
* mapView.invalidate(); } });
*
* return true; }
@@ -1163,6 +1197,20 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
return true;
+ } else if (poi.type == POI.BUILDING) {
+ Building building = (Building) poi;
+
+ Log.i(TAG, "Pressed " + building.id);
+
+ Uri uri = Uri.parse("http://id.southampton.ac.uk/building/" + building.id);
+
+ Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath());
+
+ Intent buildingIntent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(buildingIntent);
+
+ return true;
+
} else {
myLocationOverlay.disableFollowLocation();
diff --git a/src/net/cbaines/suma/POIArrayAdapter.java b/src/net/cbaines/suma/POIArrayAdapter.java
index e35acf4..f9b5271 100644
--- a/src/net/cbaines/suma/POIArrayAdapter.java
+++ b/src/net/cbaines/suma/POIArrayAdapter.java
@@ -21,7 +21,6 @@ package net.cbaines.suma;
import java.util.List;
-
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
@@ -29,51 +28,52 @@ import android.widget.BaseAdapter;
public class POIArrayAdapter extends BaseAdapter {
- private final Context context;
- private final List<POI> POIs;
-
- public POIArrayAdapter(Context context, List<POI> pois) {
- this.context = context;
- this.POIs = pois;
- }
+ private final Context context;
+ private final List<? extends POI> POIs;
- public View getView(int position, View convertView, ViewGroup parent) {
- POIView poiView;
- if (convertView == null) {
- if (POIs.get(position).distTo == -1) {
- poiView = new POIView(context, POIs.get(position));
- } else {
- poiView = new POIView(context, POIs.get(position), POIs.get(position).distTo);
- }
- } else {
- poiView = (POIView) convertView;
- if (POIs.get(position).distTo == -1) {
- poiView = new POIView(context, POIs.get(position));
- } else {
- poiView = new POIView(context, POIs.get(position), POIs.get(position).distTo);
- }
+ public POIArrayAdapter(Context context, List<? extends POI> pois) {
+ this.context = context;
+ this.POIs = pois;
}
- return poiView;
- }
+ public View getView(int position, View convertView, ViewGroup parent) {
+ POIView poiView;
+ POI poi = POIs.get(position);
+ if (convertView == null) {
+ if (poi.distTo == -1) {
+ poiView = new POIView(context, poi);
+ } else {
+ poiView = new POIView(context, poi, poi.distTo);
+ }
+ } else {
+ poiView = (POIView) convertView;
+ if (((POI) POIs.get(position)).distTo == -1) {
+ poiView = new POIView(context, poi);
+ } else {
+ poiView = new POIView(context, poi, poi.distTo);
+ }
+ }
- public int getCount() {
- return POIs.size();
- }
+ return poiView;
+ }
- public Object getItem(int position) {
- return position;
- }
+ public int getCount() {
+ return POIs.size();
+ }
- public POI getPOIItem(int position) {
- return POIs.get(position);
- }
+ public Object getItem(int position) {
+ return position;
+ }
- public long getItemId(int position) {
- return position;
- }
+ public POI getPOIItem(int position) {
+ return (POI) POIs.get(position);
+ }
+
+ public long getItemId(int position) {
+ return position;
+ }
- public String getItemStringId(int position) {
- return POIs.get(position).id;
- }
+ public String getItemStringId(int position) {
+ return ((POI) POIs.get(position)).id;
+ }
} \ No newline at end of file
diff --git a/src/net/cbaines/suma/POIDialog.java b/src/net/cbaines/suma/POIDialog.java
index 20304bb..dd871fd 100644
--- a/src/net/cbaines/suma/POIDialog.java
+++ b/src/net/cbaines/suma/POIDialog.java
@@ -31,62 +31,62 @@ import android.widget.TextView;
public class POIDialog extends Dialog {
- // private static final String TAG = "POIDialog";
- private ListView listItems;
+ // private static final String TAG = "POIDialog";
+ private ListView listItems;
- private final Context context;
+ private final Context context;
- private final TextView message;
+ private final TextView message;
- protected POIArrayAdapter adapter;
+ protected POIArrayAdapter adapter;
- public POIDialog(Context context) {
- super(context);
+ public POIDialog(Context context) {
+ super(context);
- this.context = context;
+ this.context = context;
- setContentView(R.layout.poi_dialog);
+ setContentView(R.layout.poi_dialog);
- message = (TextView) findViewById(R.id.favouriteDialogMessage);
- listItems = (ListView) findViewById(R.id.favouriteListItems);
+ message = (TextView) findViewById(R.id.favouriteDialogMessage);
+ listItems = (ListView) findViewById(R.id.favouriteListItems);
- }
+ }
- void setMessage(final String text) {
- message.post(new Runnable() {
- public void run() {
- if (text == null || text.length() == 0) {
- message.setVisibility(View.GONE);
- } else {
- message.setText(text);
- message.setVisibility(View.VISIBLE);
- }
- }
- });
- }
+ void setMessage(final String text) {
+ message.post(new Runnable() {
+ public void run() {
+ if (text == null || text.length() == 0) {
+ message.setVisibility(View.GONE);
+ } else {
+ message.setText(text);
+ message.setVisibility(View.VISIBLE);
+ }
+ }
+ });
+ }
- void setItems(final List<POI> items) {
- listItems.post(new Runnable() {
- public void run() {
- if (items != null) {
- adapter = new POIArrayAdapter(context, items);
+ void setItems(final List<POI> items) {
+ listItems.post(new Runnable() {
+ public void run() {
+ if (items != null) {
+ adapter = new POIArrayAdapter(context, items);
- listItems.setVisibility(View.VISIBLE);
- listItems.setAdapter(adapter);
- } else {
- listItems.setVisibility(View.GONE);
- }
- }
- });
- }
+ listItems.setVisibility(View.VISIBLE);
+ listItems.setAdapter(adapter);
+ } else {
+ listItems.setVisibility(View.GONE);
+ }
+ }
+ });
+ }
- void setOnItemClickListener(OnItemClickListener item) {
- listItems.setOnItemClickListener(item);
+ void setOnItemClickListener(OnItemClickListener item) {
+ listItems.setOnItemClickListener(item);
- }
+ }
- void setOnItemLongClickListener(OnItemLongClickListener item) {
- listItems.setOnItemLongClickListener(item);
- }
+ void setOnItemLongClickListener(OnItemLongClickListener item) {
+ listItems.setOnItemLongClickListener(item);
+ }
}
diff --git a/src/net/cbaines/suma/POIView.java b/src/net/cbaines/suma/POIView.java
index fb8a6c6..b27b4f3 100644
--- a/src/net/cbaines/suma/POIView.java
+++ b/src/net/cbaines/suma/POIView.java
@@ -29,96 +29,97 @@ import android.widget.TextView;
public class POIView extends LinearLayout {
- private final static String TAG = "POIView";
+ private final static String TAG = "POIView";
- private final TextView name;
- private final TextView dist;
- private final BusRoutesView routes;
+ private final TextView name;
+ private final TextView dist;
+ private final BusRoutesView routes;
- private LayoutParams textLayoutParams;
+ private LayoutParams textLayoutParams;
- final int width;
+ final int width;
- public POIView(Context context, POI poi) {
- this(context, poi, -1);
- }
+ public POIView(Context context, POI poi) {
+ this(context, poi, -1);
+ }
- public POIView(Context context, POI poi, int distInM) {
- super(context);
+ public POIView(Context context, POI poi, int distInM) {
+ super(context);
- Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
- width = display.getWidth();
- // int height = display.getHeight();
+ Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
+ width = display.getWidth();
+ // int height = display.getHeight();
- this.setOrientation(HORIZONTAL);
+ this.setOrientation(HORIZONTAL);
- name = new TextView(context);
- name.setTextSize(16f);
- name.setGravity(Gravity.LEFT);
+ name = new TextView(context);
+ name.setTextSize(16f);
+ name.setGravity(Gravity.LEFT);
- dist = new TextView(context);
- dist.setTextSize(16f);
- dist.setGravity(Gravity.RIGHT);
+ dist = new TextView(context);
+ dist.setTextSize(16f);
+ dist.setGravity(Gravity.RIGHT);
- routes = new BusRoutesView(context, (byte) 0);
+ routes = new BusRoutesView(context, (byte) 0);
- textLayoutParams = new LayoutParams(width - (width / 4), LayoutParams.WRAP_CONTENT);
- LayoutParams distLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
- LayoutParams busRouteLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ textLayoutParams = new LayoutParams(width - (width / 4), LayoutParams.WRAP_CONTENT);
+ LayoutParams distLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
+ LayoutParams busRouteLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
- setPOIAndDist(poi, distInM);
+ setPOIAndDist(poi, distInM);
- addView(routes, busRouteLayoutParams);
- addView(name, textLayoutParams);
- addView(dist, distLayoutParams);
- }
+ addView(routes, busRouteLayoutParams);
+ addView(name, textLayoutParams);
+ addView(dist, distLayoutParams);
+ }
- public void setPOI(POI poi) {
- setPOIAndDist(poi, -1);
- }
+ public void setPOI(POI poi) {
+ setPOIAndDist(poi, -1);
+ }
- public void setPOIAndDist(POI poi, int distInM) {
+ public void setPOIAndDist(POI poi, int distInM) {
- // Log.i(TAG, "Looking at poi " + poi.id);
+ // Log.i(TAG, "Looking at poi " + poi.id);
- if (poi.type == POI.BUILDING) {
- Building building = (Building) poi;
- // Log.i(TAG, "Its a building of name " + building.name);
+ if (poi.type == POI.BUILDING) {
+ Building building = (Building) poi;
+ // Log.i(TAG, "Its a building of name " + building.name);
- name.setText(building.name + " (" + building.id + ")");
- } else if (poi.type == POI.BUS_STOP) {
+ name.setText(building.name + " (" + building.id + ")");
+ } else if (poi.type == POI.BUS_STOP) {
- BusStop busStop = (BusStop) poi;
- // Log.i(TAG, "Its a bus stop of description " + busStop.description);
+ BusStop busStop = (BusStop) poi;
+ // Log.i(TAG, "Its a bus stop of description " +
+ // busStop.description);
- name.setText(busStop.description + " (" + busStop.id + ")");
+ name.setText(busStop.description + " (" + busStop.id + ")");
- routes.setRoutes(busStop.routes);
+ routes.setRoutes(busStop.routes);
- } else if (poi.type == POI.SITE) {
+ } else if (poi.type == POI.SITE) {
- Site site = (Site) poi;
- // Log.i(TAG, "Its a site of name " + site.name);
+ Site site = (Site) poi;
+ // Log.i(TAG, "Its a site of name " + site.name);
- name.setText(site.name + " (" + site.id + ")");
- } else {
- Log.w(TAG, "Cant identify " + poi.type);
+ name.setText(site.name + " (" + site.id + ")");
+ } else {
+ Log.w(TAG, "Cant identify " + poi.type);
- name.setText(poi.id);
- }
+ name.setText(poi.id);
+ }
+
+ textLayoutParams = new LayoutParams(width - (width / 4), LayoutParams.WRAP_CONTENT);
- textLayoutParams = new LayoutParams(width - (width / 4), LayoutParams.WRAP_CONTENT);
-
- if (distInM != -1) {
- textLayoutParams.width = width - (width / 4);
- name.requestLayout();
- dist.setText(String.valueOf(distInM) + "m");
- } else {
- textLayoutParams.width = LayoutParams.FILL_PARENT;
- name.requestLayout();
- dist.setText("");
- // Log.w("POIView", "No dist avalible for S" + poi.id);
+ if (distInM != -1) {
+ textLayoutParams.width = width - (width / 4);
+ name.requestLayout();
+ dist.setText(String.valueOf(distInM) + "m");
+ } else {
+ textLayoutParams.width = LayoutParams.FILL_PARENT;
+ name.requestLayout();
+ dist.setText("");
+ // Log.w("POIView", "No dist avalible for S" + poi.id);
+ }
}
- }
} \ No newline at end of file
diff --git a/src/net/cbaines/suma/Waypoint.java b/src/net/cbaines/suma/Waypoint.java
deleted file mode 100644
index d56c05d..0000000
--- a/src/net/cbaines/suma/Waypoint.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Southampton University Map App
- * Copyright (C) 2011 Christopher Baines
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package net.cbaines.suma;
-
-import org.osmdroid.util.GeoPoint;
-
-import com.j256.ormlite.table.DatabaseTable;
-
-@DatabaseTable(tableName = "routeWaypoints")
-public class Waypoint extends POI {
-
- Waypoint() {
- }
-
- int sequence;
-
- String route;
-
- public Waypoint(int sequence, GeoPoint point) {
- super(point.toDoubleString() + ":" + sequence, point);
- this.type = POI.WAYPOINT;
- this.sequence = sequence;
- }
-
-}