aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/BusActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/BusActivity.java')
-rw-r--r--src/net/cbaines/suma/BusActivity.java59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index 04fe6cf..8d7dcbe 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -113,7 +113,8 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
timetableView = (ListView) findViewById(R.id.busActivityTimes);
if (bus.id != null) {
- // Log.i(TAG, "Bus id is not null (" + bus.id + ") setting busIDTextView");
+ // Log.i(TAG, "Bus id is not null (" + bus.id +
+ // ") setting busIDTextView");
busIDTextView.setText(bus.id + " " + bus.getName());
} else {
Log.w(TAG, "Bus id is null?");
@@ -122,9 +123,10 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
if (bus.destinationString != null) {
- // Log.i(TAG, "Bus destination string is " + bus.destinationString);
- busDestTextView
- .setText(getResources().getString(R.string.bus_activity_destination_label) + bus.destinationString);
+ // Log.i(TAG, "Bus destination string is " +
+ // bus.destinationString);
+ busDestTextView.setText(getResources().getString(R.string.bus_activity_destination_label)
+ + bus.destinationString);
busDestTextView.setVisibility(View.VISIBLE);
} else {
// Log.i(TAG, "Bus destination string is null");
@@ -132,20 +134,20 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
busDestTextView.setVisibility(View.VISIBLE);
}
- busStops = bus.route.getRouteSection(instance, bus.direction);
+ busStops = bus.route.getRouteBusStops(this);
// Log.i(TAG, "Got " + busStops.size() + " bus stops for this bus");
if (bus.destination != null) {
Log.i(TAG, "Bus destination is " + bus.destination);
- int index = busStops.indexOf(bus.destination);
- if (index != -1) {
- Log.v(TAG, "Found destination stop in busStops");
- for (int i = index + 1; i < busStops.size(); i++) {
- Log.v(TAG, "Removing " + busStops.get(i));
- busStops.remove(i);
- }
- }
+ // int index = busStops.indexOf(bus.destination);
+ // if (index != -1) {
+ // Log.v(TAG, "Found destination stop in busStops");
+ // for (int i = index + 1; i < busStops.size(); i++) {
+ // Log.v(TAG, "Removing " + busStops.get(i));
+ // busStops.remove(i);
+ // }
+ // }
} else {
Log.i(TAG, "Bus destination is null");
}
@@ -154,14 +156,17 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
public void run() {
Log.v(TAG, "Refreshing data " + (System.currentTimeMillis() - timeOfLastRefresh));
timeOfLastRefresh = System.currentTimeMillis();
- for (int num = timetableView.getFirstVisiblePosition(); num <= timetableView.getLastVisiblePosition(); num++) {
+ for (int num = timetableView.getFirstVisiblePosition(); num <= timetableView
+ .getLastVisiblePosition(); num++) {
final Stop stop = timetable.get(num);
if (System.currentTimeMillis() - stop.timeOfFetch.getTime() > 20000) {
GetTimetableStopTask task = tasks.get(busStops.get(num));
if (task != null) { // If there is a taks
- if (task.getStatus() == AsyncTask.Status.FINISHED) { // If its finished
+ if (task.getStatus() == AsyncTask.Status.FINISHED) { // If
+ // its
+ // finished
task = null; // Delete it
}
}
@@ -171,9 +176,10 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
// Remove the old time from the timetable
synchronized (timetable) {
- timetable.set(num,
- new StopLoading(bus, busStops.get(num), null, new Date(
- System.currentTimeMillis() - 21000), false));
+ timetable.set(
+ num,
+ new StopLoading(bus, busStops.get(num), null, new Date(System
+ .currentTimeMillis() - 21000), false));
displayTimetable(timetable);
}
@@ -217,9 +223,10 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
Log.i(TAG, "No Previous timetable");
timetable = new Timetable();
for (int i = 0; i < busStops.size(); i++) {
- // Add a loading stop, with a fetch time such that it will be fetched
- timetable
- .add(new StopLoading(bus, busStops.get(i), null, new Date(System.currentTimeMillis() - 21000), false));
+ // Add a loading stop, with a fetch time such that it will
+ // be fetched
+ timetable.add(new StopLoading(bus, busStops.get(i), null, new Date(
+ System.currentTimeMillis() - 21000), false));
}
// Log.v(TAG, "Finished adding placeholder stops");
} else {
@@ -272,8 +279,9 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
// Remove the old time from the timetable
synchronized (timetable) {
- timetable.set(num, new StopLoading(bus, busStops.get(num), null, new Date(
- System.currentTimeMillis() - 21000), false));
+ timetable.set(num,
+ new StopLoading(bus, busStops.get(num), null, new Date(
+ System.currentTimeMillis() - 21000), false));
displayTimetable(timetable);
}
@@ -312,7 +320,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
try {
// Log.i(TAG, "Fetching stop for busStop " + position);
- stop = DataManager.getStop(instance, bus, busStop);
+ stop = DataManager.getStop(instance, bus, position);
if (stop == null) {
stop = new Stop(bus, busStop, null, new Date(System.currentTimeMillis()), false);
}
@@ -324,7 +332,8 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
// errorMessage = "ClientProtocolException!?!";
e.printStackTrace();
} catch (IOException e) {
- // errorMessage = "Error fetching bus times from server, are you connected to the internet?";
+ // errorMessage =
+ // "Error fetching bus times from server, are you connected to the internet?";
e.printStackTrace();
} catch (JSONException e) {
// errorMessage = "Error parsing bus times";