aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/routestops.csv104
-rw-r--r--src/net/cbaines/suma/Bus.java3
-rw-r--r--src/net/cbaines/suma/BusActivity.java49
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java10
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java16
-rw-r--r--src/net/cbaines/suma/BusStopSpecificStopView.java11
-rw-r--r--src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java15
-rw-r--r--src/net/cbaines/suma/DataManager.java10
8 files changed, 102 insertions, 116 deletions
diff --git a/assets/routestops.csv b/assets/routestops.csv
index 0c26511..02897e8 100644
--- a/assets/routestops.csv
+++ b/assets/routestops.csv
@@ -2931,58 +2931,43 @@
326,34,HAA13386
326,35,SN120998
326,36,HA030183
-326,37,HA030200
-326,38,HAA09425
-326,39,HA030198
-326,40,HA030203
-326,41,HA030204
-326,42,HA030206
-326,43,HA030212
-326,44,HA030212
-326,45,HA030207
-326,46,HA030205
-326,47,HA030202
-326,48,HA030199
-326,49,HAA09426
-326,50,HA030201
-326,51,HA030183
-326,52,HA030184
-326,53,HAA09424
-326,54,SN120999
-326,55,SN120164
-326,56,SN120163
-326,57,HAA13651
-326,58,SNA19780
-326,59,HAA13381
-326,60,SN120147
-326,61,SN120145
-326,62,SN120140
-326,63,SN120136
-326,64,SN120134
-326,65,HAA13668
-326,66,SN120256
-326,67,SN120266
-326,68,SN120269
-326,69,SN12275A
-326,70,SN120278
-326,71,SN120280
-326,72,SN120283
-326,73,SN120399
-326,74,SN120400
-326,75,SN120404
-326,76,SN120406
-326,77,SN120536
-326,78,SNA40402
-326,79,SN120525
-326,80,HAA13584
-326,81,SN120520
-326,82,SN121031
-326,83,HAA13583
-326,84,HA120626
-326,85,SNA13769
-326,86,SNA13766
-326,87,SNA09285
-326,88,MG1031
+326,37,HA030184
+326,38,HAA09424
+326,39,SN120999
+326,40,SN120164
+326,41,SN120163
+326,42,HAA13651
+326,43,SNA19780
+326,44,HAA13381
+326,45,SN120147
+326,46,SN120145
+326,47,SN120140
+326,48,SN120136
+326,49,SN120134
+326,50,HAA13668
+326,51,SN120256
+326,52,SN120266
+326,53,SN120269
+326,54,SN12275A
+326,55,SN120278
+326,56,SN120280
+326,57,SN120283
+326,58,SN120399
+326,59,SN120400
+326,60,SN120404
+326,61,SN120406
+326,62,SN120536
+326,63,SNA40402
+326,64,SN120525
+326,65,HAA13584
+326,66,SN120520
+326,67,SN121031
+326,68,HAA13583
+326,69,HA120626
+326,70,SNA13769
+326,71,SNA13766
+326,72,SNA09285
+326,73,MG1031
468,1,HAA13649
468,2,SNA13768
468,3,HA120625
@@ -3329,6 +3314,21 @@
999,34,HAA13386
999,35,SN120998
999,36,HA030183
+999,37,HA030200
+999,38,HAA09425
+999,39,HA030198
+999,40,HA030203
+999,41,HA030204
+999,42,HA030206
+999,43,HA030212
+999,44,HA030212
+999,45,HA030207
+999,46,HA030205
+999,47,HA030202
+999,48,HA030199
+999,49,HAA09426
+999,50,HA030201
+999,51,HA030183
999,52,HA030184
999,53,HAA09424
999,54,SN120999
diff --git a/src/net/cbaines/suma/Bus.java b/src/net/cbaines/suma/Bus.java
index 5cbf375..d971dac 100644
--- a/src/net/cbaines/suma/Bus.java
+++ b/src/net/cbaines/suma/Bus.java
@@ -56,9 +56,6 @@ public class Bus {
*/
String destinationString;
- Bus() {
- }
-
/**
* Create a bus.
*
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index 368d514..1659c88 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -131,12 +131,19 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
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(num);
+
+ if (task != null) { // If there is a task
+ if (task.getStatus() == AsyncTask.Status.FINISHED) {
+ task = null; // Delete it
+ }
+ }
+
+ if (System.currentTimeMillis() - stop.timeOfFetch.getTime() > 20000 && task == null) {
refreshBusStop(num);
} else {
// Log.v(TAG, "Not updating " + busStops.get(num));
}
-
}
handler.postDelayed(refreshData, 50000);
}
@@ -147,30 +154,20 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
private void refreshBusStop(int index) {
- GetTimetableStopTask task = tasks.get(index);
- if (task != null) { // If there is a taks
- if (task.getStatus() == AsyncTask.Status.FINISHED) { // If
- // its
- // finished
- task = null; // Delete it
- }
+ // Remove the old time from the timetable
+ synchronized (timetable) {
+ timetable.set(index, new StopLoading(timetable.get(index).bus, busStops.get(index), timetable.get(index).arivalTime,
+ new Date(System.currentTimeMillis() - 21000), false));
+ displayTimetable();
}
- if (task == null) { // If there is now no task
- // Log.v(TAG, "Updating " + busStops.get(num));
-
- // Remove the old time from the timetable
- synchronized (timetable) {
- timetable.set(index, new StopLoading(timetable.get(index).bus, busStops.get(index),
- timetable.get(index).arivalTime, new Date(System.currentTimeMillis() - 21000), false));
- displayTimetable();
- }
-
- task = new GetTimetableStopTask();
- task.execute(index);
+ GetTimetableStopTask task = new GetTimetableStopTask();
+ task.execute(index);
+ synchronized (tasks) {
tasks.put(index, task);
}
+
}
@Override
@@ -262,16 +259,10 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
private class GetTimetableStopTask extends AsyncTask<Integer, Integer, Stop> {
// private String errorMessage;
- private BusStop busStop;
-
private int busStopIndex;
- protected void onPreExecute() {
- // progBar.setVisibility(View.VISIBLE);
- }
-
protected Stop doInBackground(Integer... busStopIndexs) {
- busStop = busStops.get(busStopIndexs[0]);
+ BusStop busStop = busStops.get(busStopIndexs[0]);
busStopIndex = busStopIndexs[0];
Stop stop = null;
@@ -300,7 +291,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
protected void onPostExecute(Stop stop) {
- // Log.i(TAG, "Got timetable");
+ if (isCancelled()) return;
synchronized (timetable) {
timetable.set(busStopIndex, stop);
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index ca8cdbb..df77d46 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -97,12 +97,7 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
if (stop.arivalTime != null) { // Time available
time.setText(stop.getShortTimeToArival());
time.setVisibility(View.VISIBLE);
- } else { // No time available (yet) and not currently loading
- time.setVisibility(View.GONE);
- time.setText("");
- }
- if (stop.arivalTime != null) {
if (stop.live) {
onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
+ DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
@@ -110,7 +105,10 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
+ DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)";
}
- } else {
+ } else { // No time available (yet) and not currently loading
+ time.setVisibility(View.GONE);
+ time.setText("");
+
onClickMessage = stop.busStop.description + " on route, but arival time is not avalible";
}
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index e28086a..4c4699f 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -59,10 +59,10 @@ import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
-public class BusStopActivity extends ToastHelperActivity implements OnCheckedChangeListener, Preferences,
- OnItemClickListener, OnLongClickListener {
+public class BusStopActivity extends ToastHelperActivity implements OnCheckedChangeListener, Preferences, OnItemClickListener,
+ OnLongClickListener {
- final static String TAG = "BusTimeActivity";
+ final static String TAG = "BusStopActivity";
private ListView busTimeList;
private TextView busName;
@@ -308,7 +308,7 @@ public class BusStopActivity extends ToastHelperActivity implements OnCheckedCha
return timetable;
}
- private class GetTimetableTask extends AsyncTask<String, Integer, Timetable> {
+ private class GetTimetableTask extends AsyncTask<String, Integer, Timetable> {
String errorMessage;
protected void onPreExecute() {
@@ -320,10 +320,10 @@ public class BusStopActivity extends ToastHelperActivity implements OnCheckedCha
try {
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance);
- newTimetable = DataManager.getTimetable(instance, busStop.id, sharedPrefs.getBoolean(
- MapActivity.UNI_LINK_BUS_TIMES, MapActivity.UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT), sharedPrefs
- .getBoolean(MapActivity.NON_UNI_LINK_BUS_TIMES,
- MapActivity.NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT));
+ newTimetable = DataManager
+ .getTimetable(instance, busStop.id, sharedPrefs.getBoolean(MapActivity.UNI_LINK_BUS_TIMES,
+ MapActivity.UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT), sharedPrefs.getBoolean(
+ MapActivity.NON_UNI_LINK_BUS_TIMES, MapActivity.NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT));
} catch (SQLException e) {
errorMessage = "Error message regarding SQL?";
e.printStackTrace();
diff --git a/src/net/cbaines/suma/BusStopSpecificStopView.java b/src/net/cbaines/suma/BusStopSpecificStopView.java
index 2124308..f266464 100644
--- a/src/net/cbaines/suma/BusStopSpecificStopView.java
+++ b/src/net/cbaines/suma/BusStopSpecificStopView.java
@@ -41,7 +41,7 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
// private final ImageView icon;
- private static final String TAG = "StopView";
+ private static final String TAG = "BusStopSpecificStopView";
private final TextView name;
private final TextView time;
@@ -112,11 +112,11 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
public void onClick(View v) {
Log.v(TAG, "onClick");
- if (stop.bus != null) {
- Log.v(TAG, "stop.bus != null");
+ if (stop.bus.id != null && stop.bus.route.uniLink) {
+ // Log.v(TAG, "stop.bus != null");
context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
} else {
- Log.v(TAG, "stop.bus == null");
+ // Log.v(TAG, "stop.bus == null");
context.makeToast(onClickMessage, Toast.LENGTH_SHORT);
}
}
@@ -126,12 +126,11 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
try {
Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao();
-
busRouteDao.refresh(stop.bus.route);
Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID " + stop.bus.id);
- if (stop.bus != null && stop.bus.route.uniLink) {
+ if (stop.bus.id != null && stop.bus.route.uniLink) {
Uri uri = Uri.parse("http://id.southampton.ac.uk/bus/" + stop.bus.id);
Intent busIntent = new Intent(Intent.ACTION_VIEW, uri);
diff --git a/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java b/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java
index 511f427..cd2a5cf 100644
--- a/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java
+++ b/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java
@@ -19,7 +19,6 @@
package net.cbaines.suma;
-import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
@@ -33,7 +32,7 @@ public class BusStopSpecificTimetableAdapter extends BaseAdapter {
private final Animation a;
private boolean[] changed;
- private static final String TAG = "TimetableAdapter";
+ // private static final String TAG = "BusStopSpecificTimetableAdapter";
public BusStopSpecificTimetableAdapter(BusStopActivity context, Timetable timetable) {
this.context = context;
@@ -42,7 +41,7 @@ public class BusStopSpecificTimetableAdapter extends BaseAdapter {
}
public View getView(int position, View convertView, ViewGroup parent) {
- Log.i(TAG, "Returning stop " + position + " " + timetable.get(position));
+ // Log.i(TAG, "Returning stop " + position + " " + timetable.get(position));
BusStopSpecificStopView stopView;
if (convertView == null) {
@@ -55,7 +54,7 @@ public class BusStopSpecificTimetableAdapter extends BaseAdapter {
if (changed == null || changed[position]) {
a.reset();
stopView.startAnimation(a);
- Log.i(TAG, "Animating it");
+ // Log.i(TAG, "Animating it");
}
return stopView;
@@ -74,15 +73,15 @@ public class BusStopSpecificTimetableAdapter extends BaseAdapter {
}
public void updateTimetable(Timetable newTimetable) {
- Log.v(TAG, "Old timetable " + timetable);
- Log.v(TAG, "Adaptor loading new timetable");
+ // 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 (!timetable.contains(newTimetable.get(i), true)) {
changed[i] = true;
- Log.i(TAG, "Old timetable does not contain: " + newTimetable.get(i));
+ // Log.i(TAG, "Old timetable does not contain: " + newTimetable.get(i));
} else {
- Log.i(TAG, "Old timetable contains: " + newTimetable.get(i));
+ // Log.i(TAG, "Old timetable contains: " + newTimetable.get(i));
changed[i] = false;
}
}
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index 97ebb54..1658cb5 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -683,6 +683,7 @@ public class DataManager {
for (int stopNum = 0; stopNum < stopsArray.length(); stopNum++) {
JSONObject stopObj = stopsArray.getJSONObject(stopNum);
+ Log.v(TAG, stopObj.toString());
if (!keepNonUniLink && !stopObj.getString("name").startsWith("U")) {
// Log.v(TAG, "Skipping non uni-link stop " +
@@ -863,12 +864,12 @@ public class DataManager {
if (route.id == 326) { // U1
Log.i(TAG, "Direction for " + busStopRouteIndex + " is");
- if (busStopRouteIndex >= 0 && busStopRouteIndex <= 36) {
+ if (busStopRouteIndex >= 0 && busStopRouteIndex <= 35) {
direction = route.forwardDirection;
- } else if (busStopRouteIndex >= 50 && busStopRouteIndex <= 87) {
+ } else if (busStopRouteIndex >= 52 && busStopRouteIndex <= 87) {
direction = route.reverseDirection;
} else {
- Log.e(TAG, "For U1 route, error with busStopRouteIndex " + busStopRouteIndex);
+ Log.e(TAG, "For U1 route, error with busStopRouteIndex " + busStopRouteIndex + " " + busStop.description);
}
Log.i(TAG, direction);
} else if (route.id == 468) { // U1N
@@ -957,12 +958,13 @@ public class DataManager {
}
public static String getFileFromServer(String request) throws ClientProtocolException, IOException {
+ long requestStartTime = System.currentTimeMillis();
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(request);
- // Log.v("Util.getFileFromServer", "Request used: " + request);
HttpResponse response = client.execute(httpGet);
+ Log.v("Util.getFileFromServer", request + " request took " + (System.currentTimeMillis() - requestStartTime));
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {