diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-02-19 09:41:44 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-02-19 09:41:44 +0000 |
commit | bff738801d5a231806c42bcb06b1e187d120b5a9 (patch) | |
tree | 1ed698d5b742226a67fa52844a2fd72dea474ae9 /src/net/cbaines/suma/BusActivity.java | |
parent | 7bb198687abe16bc457c96b77dc07283b0340832 (diff) | |
download | southamptonuniversitymap-bff738801d5a231806c42bcb06b1e187d120b5a9.tar southamptonuniversitymap-bff738801d5a231806c42bcb06b1e187d120b5a9.tar.gz |
Fixed a bug with the MapActivity overlay toasts, and improved the BusStopActivity.
Diffstat (limited to 'src/net/cbaines/suma/BusActivity.java')
-rw-r--r-- | src/net/cbaines/suma/BusActivity.java | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java index d632298..b802cfb 100644 --- a/src/net/cbaines/suma/BusActivity.java +++ b/src/net/cbaines/suma/BusActivity.java @@ -2,7 +2,6 @@ package net.cbaines.suma; import java.io.IOException; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -61,7 +60,6 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements // BusStops and if they are being updated by the handler List<BusStop> busStops; - ArrayList<Boolean> busStopsActive; private HashMap<BusStop, GetTimetableStopTask> tasks = new HashMap<BusStop, GetTimetableStopTask>(); @@ -155,10 +153,6 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements busStops = bus.route.getRouteSection(instance, bus.direction); Log.i(TAG, "Got " + busStops.size() + " bus stops for this bus"); - busStopsActive = new ArrayList<Boolean>(busStops.size()); - for (int i = 0; i < busStops.size(); i++) { - busStopsActive.add(false); - } if (bus.destination != null) { Log.i(TAG, "Bus destination is " + bus.destination); @@ -167,7 +161,8 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements } /* - * for (int i = 0;; i++) { BusStop nextStop = bus.route.moveInRoute(instance, busStops.get(i), bus.direction, 1); + * for (int i = 0;; i++) { BusStop nextStop = bus.route.moveInRoute(instance, busStops.get(i), bus.direction, + * 1); * * if (nextStop.equals(busStop) || (bus.destination != null && bus.destination.equals(nextStop))) { break; } * @@ -179,27 +174,26 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements refreshData = new Runnable() { @Override public void run() { - for (int num = 0; num < timetable.size(); num++) { - if (busStopsActive.get(num)) { - Stop stop = timetable.get(num); + for (int num = timetableView.getFirstVisiblePosition(); num < timetableView.getLastVisiblePosition(); num++) { + Stop stop = timetable.get(num); - GetTimetableStopTask task = tasks.get(busStops.get(num)); + GetTimetableStopTask task = tasks.get(busStops.get(num)); - if (stop.timeOfFetch == null || (stop.timeOfFetch.getTime() - System.currentTimeMillis()) > 20000) { - if (task != null) { - if (task.getStatus() == AsyncTask.Status.FINISHED) { - task = null; - } + if (stop.timeOfFetch == null || (stop.timeOfFetch.getTime() - System.currentTimeMillis()) > 20000) { + if (task != null) { + if (task.getStatus() == AsyncTask.Status.FINISHED) { + task = null; } + } - if (task == null) { - task = new GetTimetableStopTask(); - BusStop[] str = { stop.busStop }; - task.execute(str); - tasks.put(stop.busStop, task); - } + if (task == null) { + task = new GetTimetableStopTask(); + BusStop[] str = { stop.busStop }; + task.execute(str); + tasks.put(stop.busStop, task); } } + } handler.postDelayed(refreshData, 50000); } @@ -336,7 +330,9 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements adapter = new BusSpecificTimetableAdapter(this, visibleTimetable); timetableView.setAdapter(adapter); if (busStop != null) { - Log.i(TAG, "Moving to position of " + busStop.description + " which is " + busStops.indexOf(busStop)); + Log.i(TAG, + "Moving to position of " + busStop.description + " which is " + + busStops.indexOf(busStop)); timetableView.setSelection(busStops.indexOf(busStop)); } } |