aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-17 15:07:20 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-17 15:07:20 +0000
commitc15c37286de9bb55bed43f63a38911e9633ced28 (patch)
treef21560fdd249289570a49d95680e1ad04b406676
parentfdc65e639563d145b042f9fa3d8be5b27efce8e2 (diff)
downloadsouthamptonuniversitymap-c15c37286de9bb55bed43f63a38911e9633ced28.tar
southamptonuniversitymap-c15c37286de9bb55bed43f63a38911e9633ced28.tar.gz
Somewhat working bus stop movement and bus schedule :)
-rw-r--r--src/net/cbaines/suma/BusRoute.java10
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java13
2 files changed, 10 insertions, 13 deletions
diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java
index ed6deeb..e1bf65b 100644
--- a/src/net/cbaines/suma/BusRoute.java
+++ b/src/net/cbaines/suma/BusRoute.java
@@ -122,10 +122,6 @@ public class BusRoute {
*/
Set<BusStop> moveInRoute(final Context context, final BusStop busStop, final int moveAmount) {
- if (!code.startsWith("U") || code.equals("U9")) {
- throw new RuntimeException("Route Movement not supported for " + code);
- }
-
Set<BusStop> busStops = new HashSet<BusStop>();
if (moveAmount == 0) {
@@ -185,6 +181,8 @@ public class BusRoute {
busStops.add(routeStopsFound.get(stopWanted).stop);
}
}
+
+ return busStops;
} catch (SQLException e) {
e.printStackTrace();
}
@@ -202,10 +200,6 @@ public class BusRoute {
*/
BusStop moveInRoute(final Context context, final BusStop busStop, String direction, final int moveAmount) {
- if (!code.startsWith("U") || code.equals("U9")) {
- throw new RuntimeException("Route Movement not supported for " + code);
- }
-
if (moveAmount == 0) {
return busStop;
}
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index 5928033..9910ad3 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -24,6 +24,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;
@@ -351,14 +352,16 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
for (BusRoute route : routes) {
try {
- BusStop tmpStop;
+ Set<BusStop> tmpStops;
if (item.getItemId() == R.id.menu_next_stop) {
- tmpStop = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), null, 1);
+ tmpStops = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), 1);
} else {
- tmpStop = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), null, -1);
+ tmpStops = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), -1);
}
- if (!busStops.contains(tmpStop)) {
- busStops.add(tmpStop);
+ for (BusStop busStop : tmpStops) {
+ if (!busStops.contains(busStop)) {
+ busStops.add(busStop);
+ }
}
} catch (SQLException e) {
e.printStackTrace();