From c15c37286de9bb55bed43f63a38911e9633ced28 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 17 Feb 2012 15:07:20 +0000 Subject: Somewhat working bus stop movement and bus schedule :) --- src/net/cbaines/suma/BusRoute.java | 10 ++-------- src/net/cbaines/suma/BusStopActivity.java | 13 ++++++++----- 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 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 busStops = new HashSet(); 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 impleme for (BusRoute route : routes) { try { - BusStop tmpStop; + Set 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(); -- cgit v1.2.3