aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-03-06 22:10:47 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-03-06 22:10:47 +0000
commit56c74a2fa83916915587ae2de1b46a50f2c856ee (patch)
treee6f398960a87f697c91a210b3d495c1eb4a65946
parent1b2872b6e53791cf5619a016d2b22d015544c2c8 (diff)
downloadsouthamptonuniversitymap-56c74a2fa83916915587ae2de1b46a50f2c856ee.tar
southamptonuniversitymap-56c74a2fa83916915587ae2de1b46a50f2c856ee.tar.gz
Improved Bus activity, and U6 route overlay.
-rw-r--r--gen/net/cbaines/suma/R.java114
-rw-r--r--res/layout/bus_specific_stop_view.xml28
-rw-r--r--res/raw/u6.gpx36
-rw-r--r--src/net/cbaines/suma/BusActivity.java102
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java53
-rw-r--r--src/net/cbaines/suma/BusSpecificTimetableAdapter.java41
-rw-r--r--src/net/cbaines/suma/StopLoading.java11
7 files changed, 244 insertions, 141 deletions
diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java
index 3163564..d65abc0 100644
--- a/gen/net/cbaines/suma/R.java
+++ b/gen/net/cbaines/suma/R.java
@@ -71,71 +71,75 @@ public final class R {
public static final int busRouteActivityID=0x7f0a0013;
public static final int busRouteActivityLabel=0x7f0a0012;
public static final int busRouteBusStops=0x7f0a0014;
- public static final int busStopID=0x7f0a001d;
- public static final int busStopListItems=0x7f0a0024;
- public static final int busStopLoadBar=0x7f0a0022;
- public static final int busStopMessage=0x7f0a0021;
- public static final int busStopName=0x7f0a0015;
- public static final int busStopTimes=0x7f0a001f;
- public static final int busTimeContentLayout=0x7f0a001e;
- public static final int centerLoadBar=0x7f0a0020;
- public static final int check1=0x7f0a0036;
- public static final int childname=0x7f0a0035;
- public static final int donateBitcoinAddress=0x7f0a002a;
+ public static final int busSpecificStopViewID=0x7f0a0016;
+ public static final int busSpecificStopViewName=0x7f0a0015;
+ public static final int busSpecificStopViewProgressBar=0x7f0a0017;
+ public static final int busStopID=0x7f0a0020;
+ public static final int busStopListItems=0x7f0a0027;
+ public static final int busStopLoadBar=0x7f0a0025;
+ public static final int busStopMessage=0x7f0a0024;
+ public static final int busStopName=0x7f0a0018;
+ public static final int busStopTimes=0x7f0a0022;
+ public static final int busTimeContentLayout=0x7f0a0021;
+ public static final int centerLoadBar=0x7f0a0023;
+ public static final int check1=0x7f0a0039;
+ public static final int childname=0x7f0a0038;
+ public static final int donateBitcoinAddress=0x7f0a002d;
public static final int donateButton=0x7f0a0003;
- public static final int donateDialogErrorMessage=0x7f0a0029;
- public static final int donateDialogMessage=0x7f0a0026;
- public static final int donateDialogMessageLayout=0x7f0a0028;
- public static final int donateDialogProgress=0x7f0a0027;
- public static final int favouriteCheckBox=0x7f0a001c;
- public static final int favouriteDialogMessage=0x7f0a0030;
- public static final int favouriteListItems=0x7f0a0031;
- public static final int findContentLayout=0x7f0a002c;
- public static final int findListItems=0x7f0a002e;
- public static final int findLoadBar=0x7f0a002d;
+ public static final int donateDialogErrorMessage=0x7f0a002c;
+ public static final int donateDialogMessage=0x7f0a0029;
+ public static final int donateDialogMessageLayout=0x7f0a002b;
+ public static final int donateDialogProgress=0x7f0a002a;
+ public static final int favouriteCheckBox=0x7f0a001f;
+ public static final int favouriteDialogMessage=0x7f0a0033;
+ public static final int favouriteListItems=0x7f0a0034;
+ public static final int findContentLayout=0x7f0a002f;
+ public static final int findListItems=0x7f0a0031;
+ public static final int findLoadBar=0x7f0a0030;
public static final int helpExpandableListView=0x7f0a0002;
- public static final int layout_root=0x7f0a0023;
- public static final int linearLayout1=0x7f0a0016;
- public static final int linearLayout2=0x7f0a0025;
- public static final int mapview=0x7f0a002f;
- public static final int menu_about=0x7f0a0040;
- public static final int menu_favourites=0x7f0a0041;
- public static final int menu_find=0x7f0a003c;
- public static final int menu_find_my_location=0x7f0a003e;
- public static final int menu_next_stop=0x7f0a003b;
- public static final int menu_preferences=0x7f0a003d;
- public static final int menu_previous_stop=0x7f0a0039;
- public static final int menu_refresh_bus=0x7f0a0038;
- public static final int menu_refresh_stop=0x7f0a003a;
- public static final int menu_view=0x7f0a003f;
- public static final int radio_u1=0x7f0a0017;
- public static final int radio_u1n=0x7f0a0018;
- public static final int radio_u2=0x7f0a0019;
- public static final int radio_u6=0x7f0a001a;
- public static final int radio_u9=0x7f0a001b;
- public static final int searchBar=0x7f0a002b;
+ public static final int layout_root=0x7f0a0026;
+ public static final int linearLayout1=0x7f0a0019;
+ public static final int linearLayout2=0x7f0a0028;
+ public static final int mapview=0x7f0a0032;
+ public static final int menu_about=0x7f0a0043;
+ public static final int menu_favourites=0x7f0a0044;
+ public static final int menu_find=0x7f0a003f;
+ public static final int menu_find_my_location=0x7f0a0041;
+ public static final int menu_next_stop=0x7f0a003e;
+ public static final int menu_preferences=0x7f0a0040;
+ public static final int menu_previous_stop=0x7f0a003c;
+ public static final int menu_refresh_bus=0x7f0a003b;
+ public static final int menu_refresh_stop=0x7f0a003d;
+ public static final int menu_view=0x7f0a0042;
+ public static final int radio_u1=0x7f0a001a;
+ public static final int radio_u1n=0x7f0a001b;
+ public static final int radio_u2=0x7f0a001c;
+ public static final int radio_u6=0x7f0a001d;
+ public static final int radio_u9=0x7f0a001e;
+ public static final int searchBar=0x7f0a002e;
public static final int textView1=0x7f0a0000;
public static final int textView2=0x7f0a0001;
- public static final int toastViewLinearLayout=0x7f0a0032;
- public static final int toastViewSubMessage=0x7f0a0034;
- public static final int toastViewText=0x7f0a0033;
- public static final int view_list=0x7f0a0037;
+ public static final int toastViewLinearLayout=0x7f0a0035;
+ public static final int toastViewSubMessage=0x7f0a0037;
+ public static final int toastViewText=0x7f0a0036;
+ public static final int view_list=0x7f0a003a;
}
public static final class layout {
public static final int about_dialog=0x7f030000;
public static final int building_activity=0x7f030001;
public static final int bus_activity=0x7f030002;
public static final int bus_route_activity=0x7f030003;
- public static final int bus_stop_activity=0x7f030004;
- public static final int bus_stop_dialog=0x7f030005;
- public static final int donate_dialog=0x7f030006;
- public static final int find_activity=0x7f030007;
- public static final int map_activity=0x7f030008;
- public static final int poi_dialog=0x7f030009;
- public static final int toast_view=0x7f03000a;
- public static final int view_child_row=0x7f03000b;
- public static final int view_dialog=0x7f03000c;
- public static final int view_group_row=0x7f03000d;
+ public static final int bus_specific_stop_view=0x7f030004;
+ public static final int bus_stop_activity=0x7f030005;
+ public static final int bus_stop_dialog=0x7f030006;
+ public static final int donate_dialog=0x7f030007;
+ public static final int find_activity=0x7f030008;
+ public static final int map_activity=0x7f030009;
+ public static final int poi_dialog=0x7f03000a;
+ public static final int toast_view=0x7f03000b;
+ public static final int view_child_row=0x7f03000c;
+ public static final int view_dialog=0x7f03000d;
+ public static final int view_group_row=0x7f03000e;
}
public static final class menu {
public static final int bus_menu=0x7f090000;
diff --git a/res/layout/bus_specific_stop_view.xml b/res/layout/bus_specific_stop_view.xml
new file mode 100644
index 0000000..e48e2f1
--- /dev/null
+++ b/res/layout/bus_specific_stop_view.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <TextView
+ android:id="@+id/busSpecificStopViewName"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true" />
+
+ <TextView
+ android:id="@+id/busSpecificStopViewID"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true" />
+
+ <ProgressBar
+ android:id="@+id/busSpecificStopViewProgressBar"
+ style="?android:attr/progressBarStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_toLeftOf="@+id/textView2" />
+
+</RelativeLayout> \ No newline at end of file
diff --git a/res/raw/u6.gpx b/res/raw/u6.gpx
index 5356358..c2680e0 100644
--- a/res/raw/u6.gpx
+++ b/res/raw/u6.gpx
@@ -311,19 +311,21 @@
</trkpt>
<trkpt lat="50.911125525144065" lon="-1.3997288629031808">
</trkpt>
- <trkpt lat="50.91103994792294" lon="-1.400066435302374">
+ <trkpt lat="50.911078888689055" lon="-1.4000418719938237">
</trkpt>
- <trkpt lat="50.910947315753624" lon="-1.4003299819009352">
+ <trkpt lat="50.91097696389885" lon="-1.4002541865488376">
</trkpt>
- <trkpt lat="50.910277056343" lon="-1.4003415443581355">
+ <trkpt lat="50.910828657797595" lon="-1.400307153273035">
+ </trkpt>
+ <trkpt lat="50.910273301468834" lon="-1.4003594094939522">
</trkpt>
<trkpt lat="50.91016089223864" lon="-1.400574693014231">
</trkpt>
- <trkpt lat="50.91012129039976" lon="-1.401284775406461">
+ <trkpt lat="50.9100912512976" lon="-1.401279812868734">
</trkpt>
- <trkpt lat="50.91004933459241" lon="-1.4015113722252">
+ <trkpt lat="50.91000114678214" lon="-1.401503432164837">
</trkpt>
- <trkpt lat="50.90980214895626" lon="-1.4016678478426237">
+ <trkpt lat="50.90970765023402" lon="-1.4016638778124424">
</trkpt>
<trkpt lat="50.907124626313696" lon="-1.4014818549362948">
</trkpt>
@@ -557,19 +559,27 @@
</trkpt>
<trkpt lat="50.9071240413654" lon="-1.4014866918590898">
</trkpt>
- <trkpt lat="50.90980651848476" lon="-1.4016648273423462">
+ <trkpt lat="50.909707013211666" lon="-1.40166184981971">
+ </trkpt>
+ <trkpt lat="50.90981987858249" lon="-1.4017229520499022">
+ </trkpt>
+ <trkpt lat="50.90998472289211" lon="-1.4016634779021215">
+ </trkpt>
+ <trkpt lat="50.91015807367404" lon="-1.4015830847909456">
+ </trkpt>
+ <trkpt lat="50.910454062463955" lon="-1.4016441015201093">
</trkpt>
- <trkpt lat="50.9100534525073" lon="-1.4015047464733892">
+ <trkpt lat="50.91079452209152" lon="-1.4015562870872205">
</trkpt>
- <trkpt lat="50.91012306047019" lon="-1.4012931971122498">
+ <trkpt lat="50.910986788159654" lon="-1.4013840966236517">
</trkpt>
- <trkpt lat="50.91016061102434" lon="-1.4005688652786905">
+ <trkpt lat="50.911053368882655" lon="-1.4010864625463697">
</trkpt>
- <trkpt lat="50.9102752862784" lon="-1.4003387371228724">
+ <trkpt lat="50.911031617260385" lon="-1.4005451922624754">
</trkpt>
- <trkpt lat="50.91095259624665" lon="-1.400331296209488">
+ <trkpt lat="50.91106012598475" lon="-1.4003039256656749">
</trkpt>
- <trkpt lat="50.9110417179585" lon="-1.4000692425376366">
+ <trkpt lat="50.91107977370611" lon="-1.4000425738026396">
</trkpt>
<trkpt lat="50.911122363354835" lon="-1.3997287322754564">
</trkpt>
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index f2cf133..834ce2f 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -2,6 +2,7 @@ package net.cbaines.suma;
import java.io.IOException;
import java.sql.SQLException;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -18,6 +19,7 @@ import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -57,6 +59,8 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
Handler handler;
+ long timeOfLastRefresh = 0;
+
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bus_activity);
@@ -119,8 +123,8 @@ 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);
+ 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");
@@ -139,26 +143,37 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
refreshData = new Runnable() {
public void run() {
- for (int num = timetableView.getFirstVisiblePosition(); num < timetableView
- .getLastVisiblePosition(); num++) {
- Stop stop = timetable.get(num);
+ Log.v(TAG, "Refreshing data " + (System.currentTimeMillis() - timeOfLastRefresh));
+ timeOfLastRefresh = System.currentTimeMillis();
+ for (int num = timetableView.getFirstVisiblePosition(); num < timetableView.getLastVisiblePosition(); num++) {
+ final Stop stop = timetable.get(num);
- GetTimetableStopTask task = tasks.get(busStops.get(num));
+ if (System.currentTimeMillis() - stop.timeOfFetch.getTime() > 20000) {
+ 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 (task != null) { // If there is a taks
+ if (task.getStatus() == AsyncTask.Status.FINISHED) { // If its finished
+ task = null; // Delete it
}
}
- if (task == null) {
+ 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(num, new StopLoading(bus, busStops.get(num), null, new Date(
+ System.currentTimeMillis() - 21000), false));
+ displayTimetable(timetable);
+ }
+
task = new GetTimetableStopTask();
BusStop[] str = { stop.busStop };
task.execute(str);
tasks.put(stop.busStop, task);
}
+ } else {
+ Log.v(TAG, "Not updating " + busStops.get(num));
}
}
@@ -192,12 +207,13 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
Log.i(TAG, "No Previous timetable");
timetable = new Timetable();
for (int i = 0; i < busStops.size(); i++) {
- timetable.add(new Stop(bus, busStops.get(i), null, null, 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 {
Log.i(TAG, "Displaying previous timetable");
-
}
displayTimetable(timetable);
handler.postDelayed(refreshData, 500);
@@ -225,6 +241,46 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
super.onPause();
}
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ if (item.getItemId() == R.id.menu_refresh_bus) {
+ if (handler != null) { // BusTimes are enabled
+ handler.removeCallbacks(refreshData);
+ for (GetTimetableStopTask task : tasks.values()) {
+ task.cancel(true);
+ }
+ Log.i(TAG, "Stoping refreshing timetable data");
+
+ for (int num = timetableView.getFirstVisiblePosition(); num < timetableView.getLastVisiblePosition(); num++) {
+ final Stop stop = timetable.get(num);
+
+ Log.v(TAG, "Updating " + busStops.get(num));
+
+ // 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));
+ displayTimetable(timetable);
+ }
+
+ GetTimetableStopTask task = new GetTimetableStopTask();
+ BusStop[] str = { stop.busStop };
+ task.execute(str);
+ tasks.put(stop.busStop, task);
+ }
+
+ handler.postDelayed(refreshData, 50000);
+ } else {
+ // TODO: Toast here...
+ }
+ } else {
+ Log.e(TAG, "No known menu option selected");
+ return super.onOptionsItemSelected(item);
+ }
+ return true;
+ }
+
private class GetTimetableStopTask extends AsyncTask<BusStop, Integer, Stop> {
private String errorMessage;
@@ -245,7 +301,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
Log.i(TAG, "Fetching stop for busStop " + position);
stop = DataManager.getStop(instance, bus, busStop);
if (stop == null) {
- stop = new Stop(bus, busStop, null, null, false);
+ stop = new Stop(bus, busStop, null, new Date(System.currentTimeMillis()), false);
}
Log.i(TAG, "Finished fetching stop for busStop " + position);
} catch (SQLException e) {
@@ -266,16 +322,10 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
protected void onPostExecute(Stop stop) {
// Log.i(TAG, "Got timetable");
- if (stop == null) {
- Log.i(TAG, "Its null");
- busContentMessage.setText(errorMessage);
- busContentMessage.setVisibility(View.VISIBLE);
- } else {
- synchronized (timetable) {
- timetable.set(position, stop);
- displayTimetable(timetable);
- }
+ synchronized (timetable) {
+ timetable.set(position, stop);
+ displayTimetable(timetable);
}
}
@@ -307,9 +357,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
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));
}
}
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index fdb6f56..92ec8c7 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -28,19 +28,18 @@ import android.content.res.Resources;
import android.net.Uri;
import android.util.Log;
import android.view.Gravity;
-import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
-import android.widget.LinearLayout;
import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.dao.Dao;
-public class BusSpecificStopView extends LinearLayout implements OnClickListener, OnLongClickListener {
+public class BusSpecificStopView extends RelativeLayout implements OnClickListener, OnLongClickListener {
private static final String TAG = "BusSpecificStopView";
@@ -63,14 +62,12 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
this.context = context;
- this.setOrientation(HORIZONTAL);
-
location = new TextView(context);
location.setTextSize(22f);
+ location.setGravity(Gravity.LEFT);
time = new TextView(context);
time.setTextSize(22f);
- time.setGravity(Gravity.RIGHT);
timeProgress = new ProgressBar(context, null, android.R.attr.progressBarStyleSmall);
@@ -80,9 +77,22 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
setStop(stop);
- addView(location, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- addView(time, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
- addView(timeProgress, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
+ RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.WRAP_CONTENT);
+ relativeParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+
+ RelativeLayout.LayoutParams relativeParams2 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.FILL_PARENT);
+ relativeParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+
+ addView(location, relativeParams);
+ addView(time, relativeParams2);
+
+ // LinearLayout progressLayout = new LinearLayout(context);
+ // progressLayout.setOrientation(LinearLayout.VERTICAL);
+ // progressLayout.addView(timeProgress, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+
+ addView(timeProgress, relativeParams2);
}
public void setStop(Stop stop) {
@@ -96,14 +106,19 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
} else {
location.setText(stop.busStop.description); // TODO
}
- if (stop.arivalTime != null) {
+
+ if (stop.arivalTime != null) { // Time available
time.setText(stop.getShortTimeToArival());
time.setVisibility(View.VISIBLE);
timeProgress.setVisibility(View.GONE);
- } else {
- time.setVisibility(View.GONE);
+ } else if (stop instanceof StopLoading) {
time.setText("");
+ time.setVisibility(View.GONE);
timeProgress.setVisibility(View.VISIBLE);
+ } else { // No time available (yet) and not currently loading
+ time.setVisibility(View.GONE);
+ time.setText("");
+ timeProgress.setVisibility(View.GONE);
}
DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
@@ -122,19 +137,7 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
+ DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)";
}
} else {
- if (stop.bus.id != null) {
- if (stop.live) {
- onClickMessage = "Bus " + stop.bus.toString();
- } else {
- onClickMessage = "Timetabled bus " + stop.bus.toString();
- }
- } else {
- if (stop.live) {
- onClickMessage = "Unidentified bus (" + stop.bus.getName() + ")";
- } else {
- onClickMessage = "Timetabled bus (" + stop.bus.getName() + ")";
- }
- }
+ onClickMessage = stop.busStop.description + " on route, but arival time is not avalible";
}
} catch (SQLException e) {
e.printStackTrace();
diff --git a/src/net/cbaines/suma/BusSpecificTimetableAdapter.java b/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
index 96fe713..7b9a34a 100644
--- a/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
+++ b/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
@@ -21,16 +21,14 @@ package net.cbaines.suma;
import android.view.View;
import android.view.ViewGroup;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
public class BusSpecificTimetableAdapter extends BaseAdapter {
private final BusActivity context;
private Timetable timetable;
- private final Animation a;
- private boolean[] changed;
+ // private final Animation a;
+ // private boolean[] changed;
private long timeOfLastForcedUpdate = System.currentTimeMillis();
@@ -39,7 +37,7 @@ public class BusSpecificTimetableAdapter extends BaseAdapter {
public BusSpecificTimetableAdapter(BusActivity context, Timetable timetable) {
this.context = context;
this.timetable = timetable;
- this.a = AnimationUtils.loadAnimation(context, R.anim.updated_stop_view);
+ // this.a = AnimationUtils.loadAnimation(context, R.anim.updated_stop_view);
}
public View getView(int position, View convertView, ViewGroup parent) {
@@ -47,6 +45,7 @@ public class BusSpecificTimetableAdapter extends BaseAdapter {
// timetable.get(position));
if (timeOfLastForcedUpdate + 1000 < System.currentTimeMillis()) {
+ context.handler.removeCallbacks(context.refreshData);
context.handler.post(context.refreshData);
timeOfLastForcedUpdate = System.currentTimeMillis();
}
@@ -59,11 +58,11 @@ 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");
- }
+ // if (changed == null || changed[position]) {
+ // a.reset();
+ // stopView.startAnimation(a);
+ // Log.i(TAG, "Animating it");
+ // }
return stopView;
}
@@ -83,17 +82,17 @@ 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;
- }
- }
+ // 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/StopLoading.java b/src/net/cbaines/suma/StopLoading.java
new file mode 100644
index 0000000..e8ca8e5
--- /dev/null
+++ b/src/net/cbaines/suma/StopLoading.java
@@ -0,0 +1,11 @@
+package net.cbaines.suma;
+
+import java.util.Date;
+
+public class StopLoading extends Stop {
+
+ public StopLoading(Bus bus, BusStop busStop, Date arivalTime, Date timeOfFetch, boolean live) {
+ super(bus, busStop, arivalTime, timeOfFetch, live);
+ }
+
+}