aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/cbaines/suma/BusActivity.java42
-rw-r--r--src/net/cbaines/suma/BusRoute.java9
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java1
-rw-r--r--src/net/cbaines/suma/BusSpecificTimetableAdapter.java19
-rw-r--r--src/net/cbaines/suma/DataManager.java21
5 files changed, 41 insertions, 51 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);
}
diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java
index 793cc24..e38d06a 100644
--- a/src/net/cbaines/suma/BusRoute.java
+++ b/src/net/cbaines/suma/BusRoute.java
@@ -433,8 +433,6 @@ public class BusRoute {
if (direction != null) {
- if (direction.equals("E"))
- direction = "A"; // Quick hack for U1E
} else {
throw new NullPointerException("direction is null");
}
@@ -458,11 +456,14 @@ public class BusRoute {
int endStopSeq = -1;
if (id == 326) { // U1
- if (direction.equals(forwardDirection)) {
+ if (direction.equals("E")) {
startStopSeq = 1;
endStopSeq = 43;
+ } else if (direction.equals(forwardDirection)) {
+ startStopSeq = 1;
+ endStopSeq = 36;
} else if (direction.equals(reverseDirection)) {
- startStopSeq = 44;
+ startStopSeq = 51;
endStopSeq = 88;
} else {
Log.e(TAG, "Error, unrecognised direction " + direction);
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index 79b1305..6502a5f 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -23,7 +23,6 @@ import java.sql.SQLException;
import java.text.DateFormat;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
diff --git a/src/net/cbaines/suma/BusSpecificTimetableAdapter.java b/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
index 7b9a34a..954217c 100644
--- a/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
+++ b/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
@@ -58,12 +58,6 @@ public class BusSpecificTimetableAdapter extends BaseAdapter {
stopView.setStop(timetable.get(position));
}
- // if (changed == null || changed[position]) {
- // a.reset();
- // stopView.startAnimation(a);
- // Log.i(TAG, "Animating it");
- // }
-
return stopView;
}
@@ -80,19 +74,6 @@ public class BusSpecificTimetableAdapter extends BaseAdapter {
}
public void updateTimetable(Timetable newTimetable) {
- // Log.v(TAG, "Old timetable " + timetable);
- // Log.v(TAG, "Adaptor loading new timetable");
- // changed = new boolean[newTimetable.size()];
- // for (int i = 0; i < newTimetable.size(); i++) {
- // if (newTimetable.get(i).arivalTime != null && !timetable.contains(newTimetable.get(i), true)) {
- // changed[i] = true;
- // // Log.i(TAG, "Old timetable does not contain: " +
- // // newTimetable.get(i));
- // } else {
- // // Log.i(TAG, "Old timetable contains: " + newTimetable.get(i));
- // changed[i] = false;
- // }
- // }
timetable = newTimetable;
this.notifyDataSetChanged();
}
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index ab1f3a7..08425a7 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -554,7 +554,8 @@ public class DataManager {
List<RouteStop> routeStops = routeStopsDao.query(routeStopsPreparedQuery);
if (routeStops.size() > 0) {
- Log.i(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route " + route.code);
+ // Log.i(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route " +
+ // route.code);
} else {
Log.w(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route " + route.code);
}
@@ -635,7 +636,7 @@ public class DataManager {
Iterator<String> keyIter = routesObject.keys(); keyIter.hasNext();) {
String key = keyIter.next();
- Log.v(TAG, "Route Key: " + key);
+ // Log.v(TAG, "Route Key: " + key);
BusRoute route = busRouteDao.queryForId(Integer.parseInt(key.substring(key.length() - 3, key.length())));
@@ -648,18 +649,18 @@ public class DataManager {
int age = Integer.parseInt(data.getString("age"));
- Log.v(TAG, "Stops: " + data.getJSONArray("stops"));
+ // Log.v(TAG, "Stops: " + data.getJSONArray("stops"));
for (int stopNum = 0; stopNum < stopsArray.length(); stopNum++) {
JSONObject stopObj = stopsArray.getJSONObject(stopNum);
if (!keepNonUniLink && !stopObj.getString("name").startsWith("U")) {
- Log.v(TAG, "Skipping non uni-link stop " + stopObj.getString("name"));
+ // Log.v(TAG, "Skipping non uni-link stop " + stopObj.getString("name"));
continue;
}
if (!keepUniLink && stopObj.getString("name").startsWith("U")) {
- Log.v(TAG, "Skipping uni-link stop " + stopObj.getString("name"));
+ // Log.v(TAG, "Skipping uni-link stop " + stopObj.getString("name"));
continue;
}
@@ -734,9 +735,9 @@ public class DataManager {
HashSet<BusRoute> busRoutes = new HashSet<BusRoute>();
busRoutes.add(bus.route);
- Log.v(TAG, "Number of entries " + data.length());
+ // Log.v(TAG, "Number of entries " + data.length());
- Log.v(TAG, "Stops: " + data.getJSONArray("stops"));
+ // Log.v(TAG, "Stops: " + data.getJSONArray("stops"));
for (int stopNum = 0; stopNum < stopsArray.length(); stopNum++) {
JSONObject stopObj = stopsArray.getJSONObject(stopNum);
@@ -750,8 +751,8 @@ public class DataManager {
continue;
}
- Log.v(TAG, "Found stop for a unidentified " + stop.bus.toString() + " at " + stop.busStop.id + " at "
- + stop.arivalTime);
+ // Log.v(TAG, "Found stop for a unidentified " + stop.bus.toString() + " at " + stop.busStop.id + " at "
+ // + stop.arivalTime);
timetable.add(stop);
@@ -841,7 +842,7 @@ public class DataManager {
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(request);
- Log.v("Util.getFileFromServer", "Request used: " + request);
+ // Log.v("Util.getFileFromServer", "Request used: " + request);
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();