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.java42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index ad41a6e..336d336 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -113,7 +113,7 @@ 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,21 +122,30 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
if (bus.destinationString != null) {
- Log.i(TAG, "Bus destination string is " + 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");
+ // Log.i(TAG, "Bus destination string is null");
busDestTextView.setText(getResources().getString(R.string.bus_activity_no_destination_message));
busDestTextView.setVisibility(View.VISIBLE);
}
busStops = bus.route.getRouteSection(instance, bus.direction);
- Log.i(TAG, "Got " + busStops.size() + " bus stops for this bus");
+ // 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);
+ }
+ }
} else {
Log.i(TAG, "Bus destination is null");
}
@@ -158,7 +167,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
if (task == null) { // If there is now no task
- Log.v(TAG, "Updating " + busStops.get(num));
+ // Log.v(TAG, "Updating " + busStops.get(num));
// Remove the old time from the timetable
synchronized (timetable) {
@@ -174,7 +183,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
tasks.put(stop.busStop, task);
}
} else {
- Log.v(TAG, "Not updating " + busStops.get(num));
+ // Log.v(TAG, "Not updating " + busStops.get(num));
}
}
@@ -199,7 +208,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
if (sharedPrefs.getBoolean(UNI_LINK_BUS_TIMES, UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)
|| sharedPrefs.getBoolean(NON_UNI_LINK_BUS_TIMES, NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)) {
- Log.i(TAG, "Live Times enabled");
+ // Log.i(TAG, "Live Times enabled");
timetable = (Timetable) getLastNonConfigurationInstance();
handler = new Handler();
@@ -212,11 +221,15 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
timetable
.add(new StopLoading(bus, busStops.get(i), null, new Date(System.currentTimeMillis() - 21000), false));
}
- Log.v(TAG, "Finished adding placeholder stops");
+ // Log.v(TAG, "Finished adding placeholder stops");
} else {
Log.i(TAG, "Displaying previous timetable");
}
displayTimetable(timetable);
+ if (busStop != null) {
+ Log.i(TAG, "Moving to position of " + busStop.description + " which is " + busStops.indexOf(busStop));
+ timetableView.setSelection(busStops.indexOf(busStop));
+ }
handler.postDelayed(refreshData, 500);
} else {
@@ -251,12 +264,11 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
for (GetTimetableStopTask task : tasks.values()) {
task.cancel(true);
}
- Log.i(TAG, "Stoping refreshing timetable data");
- for (int num = timetableView.getFirstVisiblePosition(); num < timetableView.getLastVisiblePosition(); num++) {
+ for (int num = timetableView.getFirstVisiblePosition(); num <= timetableView.getLastVisiblePosition(); num++) {
final Stop stop = timetable.get(num);
- Log.v(TAG, "Updating " + busStops.get(num));
+ // Log.v(TAG, "Updating " + busStops.get(num));
// Remove the old time from the timetable
synchronized (timetable) {
@@ -299,12 +311,12 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
Stop stop = null;
try {
- Log.i(TAG, "Fetching stop for busStop " + position);
+ // Log.i(TAG, "Fetching stop for busStop " + position);
stop = DataManager.getStop(instance, bus, busStop);
if (stop == null) {
stop = new Stop(bus, busStop, null, new Date(System.currentTimeMillis()), false);
}
- Log.i(TAG, "Finished fetching stop for busStop " + position);
+ // Log.i(TAG, "Finished fetching stop for busStop " + position);
} catch (SQLException e) {
// errorMessage = "Error message regarding SQL?";
e.printStackTrace();
@@ -362,10 +374,6 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
} else {
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));
- timetableView.setSelection(busStops.indexOf(busStop));
- }
}
busActivityContentLayout.setGravity(Gravity.TOP);
}