diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-01-24 23:21:55 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-01-24 23:21:55 +0000 |
commit | de2979e0f22264ada8326833bfb39746e9bf78cc (patch) | |
tree | 1a4a9cc5753eb906693275d465895d3f8c53ec0b | |
parent | efb193d6fbea2423d03eebf30e2359a6612134c1 (diff) | |
download | southamptonuniversitymap-de2979e0f22264ada8326833bfb39746e9bf78cc.tar southamptonuniversitymap-de2979e0f22264ada8326833bfb39746e9bf78cc.tar.gz |
Implemented refresh in BusTimeActivity.
-rw-r--r-- | gen/net/cbaines/suma/R.java | 57 | ||||
-rw-r--r-- | res/layout/bustimes.xml | 21 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusStopActivity.java | 41 |
3 files changed, 82 insertions, 37 deletions
diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index fff928a..9e6e829 100644 --- a/gen/net/cbaines/suma/R.java +++ b/gen/net/cbaines/suma/R.java @@ -43,48 +43,49 @@ public final class R { } public static final class id { public static final int busStopID=0x7f0a000c; - public static final int busStopLoadBar=0x7f0a000f; + public static final int busStopLoadBar=0x7f0a0011; public static final int busStopMessage=0x7f0a000e; public static final int busStopName=0x7f0a0004; - public static final int busStopTimes=0x7f0a0010; + public static final int busStopTimes=0x7f0a000f; public static final int busTimeContentLayout=0x7f0a000d; - public static final int check1=0x7f0a0020; - public static final int childname=0x7f0a001f; - public static final int donateBitcoinAddress=0x7f0a0017; + public static final int centerLoadBar=0x7f0a0010; + public static final int check1=0x7f0a0021; + public static final int childname=0x7f0a0020; + public static final int donateBitcoinAddress=0x7f0a0018; public static final int donateButton=0x7f0a0003; - public static final int donateDialogErrorMessage=0x7f0a0016; - public static final int donateDialogMessage=0x7f0a0013; - public static final int donateDialogMessageLayout=0x7f0a0015; - public static final int donateDialogProgress=0x7f0a0014; + public static final int donateDialogErrorMessage=0x7f0a0017; + public static final int donateDialogMessage=0x7f0a0014; + public static final int donateDialogMessageLayout=0x7f0a0016; + public static final int donateDialogProgress=0x7f0a0015; public static final int favouriteCheckBox=0x7f0a000b; - public static final int favouriteDialogMessage=0x7f0a0018; - public static final int favouriteListItems=0x7f0a0019; - public static final int findContentLayout=0x7f0a001b; - public static final int findListItems=0x7f0a001d; - public static final int findLoadBar=0x7f0a001c; + public static final int favouriteDialogMessage=0x7f0a0019; + public static final int favouriteListItems=0x7f0a001a; + public static final int findContentLayout=0x7f0a001c; + public static final int findListItems=0x7f0a001e; + public static final int findLoadBar=0x7f0a001d; public static final int helpExpandableListView=0x7f0a0002; - public static final int layout_root=0x7f0a0011; + public static final int layout_root=0x7f0a0012; public static final int linearLayout1=0x7f0a0005; - public static final int linearLayout2=0x7f0a0012; - public static final int mapview=0x7f0a001e; - public static final int menu_about=0x7f0a0026; - public static final int menu_favourites=0x7f0a0027; - public static final int menu_find=0x7f0a0022; - public static final int menu_find_my_location=0x7f0a0024; - public static final int menu_next_stop=0x7f0a002a; - public static final int menu_preferences=0x7f0a0023; - public static final int menu_previous_stop=0x7f0a0028; - public static final int menu_refresh_stop=0x7f0a0029; - public static final int menu_view=0x7f0a0025; + public static final int linearLayout2=0x7f0a0013; + public static final int mapview=0x7f0a001f; + public static final int menu_about=0x7f0a0027; + public static final int menu_favourites=0x7f0a0028; + public static final int menu_find=0x7f0a0023; + public static final int menu_find_my_location=0x7f0a0025; + public static final int menu_next_stop=0x7f0a002b; + public static final int menu_preferences=0x7f0a0024; + public static final int menu_previous_stop=0x7f0a0029; + public static final int menu_refresh_stop=0x7f0a002a; + public static final int menu_view=0x7f0a0026; public static final int radio_u1=0x7f0a0006; public static final int radio_u1n=0x7f0a0007; public static final int radio_u2=0x7f0a0008; public static final int radio_u6=0x7f0a0009; public static final int radio_u9=0x7f0a000a; - public static final int searchBar=0x7f0a001a; + public static final int searchBar=0x7f0a001b; public static final int textView1=0x7f0a0000; public static final int textView2=0x7f0a0001; - public static final int view_list=0x7f0a0021; + public static final int view_list=0x7f0a0022; } public static final class layout { public static final int about_dialog=0x7f030000; diff --git a/res/layout/bustimes.xml b/res/layout/bustimes.xml index 1928c79..24200c6 100644 --- a/res/layout/bustimes.xml +++ b/res/layout/bustimes.xml @@ -112,17 +112,26 @@ android:text="" android:textAppearance="?android:attr/textAppearanceLarge" /> - <ProgressBar - android:id="@+id/busStopLoadBar" - style="?android:attr/progressBarStyleLarge" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - <ListView android:id="@+id/busStopTimes" android:layout_width="fill_parent" android:layout_height="wrap_content" > </ListView> + + <LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/centerLoadBar" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:gravity="center" + android:orientation="vertical" > + + <ProgressBar + android:id="@+id/busStopLoadBar" + style="?android:attr/progressBarStyleLarge" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + </LinearLayout> </LinearLayout> </LinearLayout>
\ No newline at end of file diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java index 7fc78ce..f9e224b 100644 --- a/src/net/cbaines/suma/BusStopActivity.java +++ b/src/net/cbaines/suma/BusStopActivity.java @@ -22,8 +22,14 @@ package net.cbaines.suma; import java.sql.SQLException; import java.util.Iterator; +import org.osmdroid.util.GeoPoint; + +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; @@ -32,6 +38,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.CheckBox; import android.widget.CompoundButton; @@ -260,6 +267,10 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme } private class GetTimetableTask extends AsyncTask<String, Integer, Timetable> { + protected void onPreExecute() { + progBar.setVisibility(View.VISIBLE); + } + protected Timetable doInBackground(String... activity) { Timetable newTimetable = null; try { @@ -279,6 +290,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme busStopMessage.setText("Error fetching bus times"); busStopMessage.setVisibility(View.VISIBLE); } else { + progBar.setVisibility(View.GONE); timetable = newTimetable; displayTimetable(timetable); } @@ -292,13 +304,38 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme return true; } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle item selection + switch (item.getItemId()) { + case R.id.menu_previous_stop: + break; + case R.id.menu_next_stop: + break; + case R.id.menu_refresh_stop: + if (mHandler != null) { // BusTimes are enabled + mHandler.removeCallbacks(refreshData); + timetableTask.cancel(true); + Log.i(TAG, "Stoping refreshing timetable data"); + + mHandler.post(refreshData); + } else { + // TODO: Toast here... + } + break; + default: + Log.e(TAG, "No known menu option selected"); + return super.onOptionsItemSelected(item); + } + return true; + } + private void displayTimetable(Timetable timetable) { Timetable timetableToDisplay = (Timetable) timetable.clone(); Log.i(TAG, "It contains " + timetableToDisplay.size() + " stops"); if (timetable.size() == 0) { - progBar.setVisibility(View.GONE); busStopMessage.setText("No Busses"); busStopMessage.setVisibility(View.VISIBLE); busTimeContentLayout.setGravity(Gravity.CENTER); @@ -332,13 +369,11 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme if (timetableToDisplay.size() == 0) { busTimeContentLayout.setGravity(Gravity.CENTER); - progBar.setVisibility(View.GONE); busStopMessage.setText("No Busses (With the current enabled routes)"); busStopMessage.setVisibility(View.VISIBLE); busTimeList.setVisibility(View.GONE); } else { busTimeList.setVisibility(View.VISIBLE); - progBar.setVisibility(View.GONE); busStopMessage.setVisibility(View.GONE); TimetableAdapter adapter; if ((adapter = (TimetableAdapter) busTimeList.getAdapter()) != null) { |