aboutsummaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-03-06 15:44:49 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-03-06 15:44:49 +0000
commit1b2872b6e53791cf5619a016d2b22d015544c2c8 (patch)
tree142acf5d57575740a7eeda50fd47fb46a8e7b4cf /src/net
parent7d48b4d5c1a57ae12b55905b2f7cfa5d3623fbc6 (diff)
downloadsouthamptonuniversitymap-1b2872b6e53791cf5619a016d2b22d015544c2c8.tar
southamptonuniversitymap-1b2872b6e53791cf5619a016d2b22d015544c2c8.tar.gz
Better BusActivity.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/cbaines/suma/BusActivity.java23
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java33
-rw-r--r--src/net/cbaines/suma/BusSpecificTimetableAdapter.java4
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java14
4 files changed, 43 insertions, 31 deletions
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index 3292ce8..f2cf133 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -16,6 +16,8 @@ import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Gravity;
+import android.view.Menu;
+import android.view.MenuInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -117,8 +119,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");
@@ -137,12 +139,14 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
refreshData = new Runnable() {
public void run() {
- for (int num = timetableView.getFirstVisiblePosition(); num < timetableView.getLastVisiblePosition(); num++) {
+ for (int num = timetableView.getFirstVisiblePosition(); num < timetableView
+ .getLastVisiblePosition(); num++) {
Stop stop = timetable.get(num);
GetTimetableStopTask task = tasks.get(busStops.get(num));
- if (stop.timeOfFetch == null || (stop.timeOfFetch.getTime() - System.currentTimeMillis()) > 20000) {
+ if (stop.timeOfFetch == null
+ || (stop.timeOfFetch.getTime() - System.currentTimeMillis()) > 20000) {
if (task != null) {
if (task.getStatus() == AsyncTask.Status.FINISHED) {
task = null;
@@ -166,6 +170,13 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
}
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.bus_menu, menu);
+ return true;
+ }
+
public void onResume() {
super.onResume();
@@ -296,7 +307,9 @@ 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 6d7e6af..fdb6f56 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -28,10 +28,12 @@ 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.TextView;
import android.widget.Toast;
@@ -46,6 +48,8 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
private final TextView location;
private final TextView time;
+ private final ProgressBar timeProgress;
+
private String onClickMessage = "";
private final BusActivity context;
@@ -68,6 +72,8 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
time.setTextSize(22f);
time.setGravity(Gravity.RIGHT);
+ timeProgress = new ProgressBar(context, null, android.R.attr.progressBarStyleSmall);
+
Resources resources = context.getResources();
onClickHelpMessage = resources.getString(R.string.bus_stop_view_on_click_toast_help_message);
onClickUnidentifiedMessage = resources.getString(R.string.bus_stop_view_on_click_toast_unidentified_message);
@@ -76,7 +82,7 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
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));
}
public void setStop(Stop stop) {
@@ -92,8 +98,12 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
}
if (stop.arivalTime != null) {
time.setText(stop.getShortTimeToArival());
+ time.setVisibility(View.VISIBLE);
+ timeProgress.setVisibility(View.GONE);
} else {
+ time.setVisibility(View.GONE);
time.setText("");
+ timeProgress.setVisibility(View.VISIBLE);
}
DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
@@ -104,23 +114,12 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
busDao.refresh(stop.bus);
if (stop.arivalTime != null) {
-
- if (stop.bus.id != null) {
- if (stop.live) {
- onClickMessage = "Bus " + stop.bus.toString() + " at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- } else {
- onClickMessage = "Timetabled bus " + stop.bus.toString() + " at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- }
+ if (stop.live) {
+ onClickMessage = stop.busStop.description + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
} else {
- if (stop.live) {
- onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- } else {
- onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- }
+ onClickMessage = stop.busStop.description + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)";
}
} else {
if (stop.bus.id != null) {
diff --git a/src/net/cbaines/suma/BusSpecificTimetableAdapter.java b/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
index 7bcb560..96fe713 100644
--- a/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
+++ b/src/net/cbaines/suma/BusSpecificTimetableAdapter.java
@@ -60,8 +60,8 @@ public class BusSpecificTimetableAdapter extends BaseAdapter {
}
if (changed == null || changed[position]) {
- a.reset();
- stopView.startAnimation(a);
+ // a.reset();
+ // stopView.startAnimation(a);
// Log.i(TAG, "Animating it");
}
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index 9c49ff7..429f103 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -59,8 +59,8 @@ 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";
@@ -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();
@@ -363,7 +363,7 @@ public class BusStopActivity extends ToastHelperActivity implements OnCheckedCha
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.stop_menu, menu);
+ inflater.inflate(R.menu.bus_stop_menu, menu);
return true;
}