Added progress bar

Changed manifest to allow SD card installations
This commit is contained in:
dkeen@dkeen-laptop 2012-08-13 10:27:50 -07:00
parent 934341a1b0
commit 38c4c3bd03
4 changed files with 60 additions and 37 deletions

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dougkeen.bart" package="com.dougkeen.bart"
android:versionCode="18" android:installLocation="auto"
android:versionName="2.0.0" > android:versionCode="19"
android:versionName="2.0.1" >
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />

View File

@ -90,14 +90,21 @@
bart:tickInterval="5" /> bart:tickInterval="5" />
</RelativeLayout> </RelativeLayout>
<ListView <ProgressBar
android:id="@android:id/list" android:id="@android:id/progress"
style="@style/ProgressBarHolo.Horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="invisible" />
<TextView
android:id="@android:id/empty"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" /> android:layout_weight="1" />
<TextView <ListView
android:id="@android:id/empty" android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" /> android:layout_weight="1" />

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">BART Runner</string> <string name="app_name">BART Runner</string>
<string name="favorite_routes">Favorite routes</string> <string name="favorite_routes">Favorite routes</string>
<string name="empty_favorites_list_message">No favorite routes have been added yet</string> <string name="empty_favorites_list_message">No favorite routes have been added yet</string>
@ -19,7 +20,7 @@
http://m.bart.gov/schedules/advisories/</string> http://m.bart.gov/schedules/advisories/</string>
<string name="view">View</string> <string name="view">View</string>
<string name="view_departures">View departures</string> <string name="view_departures">View departures</string>
<string name="missing_departure">Missing departure? Inaccurate time? Please report to bartrunner@dougkeen.com</string> <string name="missing_departure">Missing/inaccurate departure? Feature request? Please report to bartrunner@dougkeen.com</string>
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="yes">Yes</string> <string name="yes">Yes</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
@ -35,4 +36,5 @@
<string name="getting_on_this_train">I will board this train</string> <string name="getting_on_this_train">I will board this train</string>
<string name="departure_options">Departure options</string> <string name="departure_options">Departure options</string>
<string name="your_train">Your train</string> <string name="your_train">Your train</string>
</resources> </resources>

View File

@ -21,6 +21,7 @@ import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -62,6 +63,7 @@ public class ViewDeparturesActivity extends SherlockListActivity {
private ScheduleInformation mLatestScheduleInfo; private ScheduleInformation mLatestScheduleInfo;
private TextView mEmptyView; private TextView mEmptyView;
private ProgressBar mProgress;
private AsyncTask<StationPair, Integer, RealTimeDepartures> mGetDeparturesTask; private AsyncTask<StationPair, Integer, RealTimeDepartures> mGetDeparturesTask;
private AsyncTask<StationPair, Integer, ScheduleInformation> mGetScheduleInformationTask; private AsyncTask<StationPair, Integer, ScheduleInformation> mGetScheduleInformationTask;
@ -107,6 +109,8 @@ public class ViewDeparturesActivity extends SherlockListActivity {
mEmptyView = (TextView) findViewById(android.R.id.empty); mEmptyView = (TextView) findViewById(android.R.id.empty);
mEmptyView.setText(R.string.departure_wait_message); mEmptyView.setText(R.string.departure_wait_message);
mProgress = (ProgressBar) findViewById(android.R.id.progress);
mDeparturesAdapter = new DepartureArrayAdapter(this, mDeparturesAdapter = new DepartureArrayAdapter(this,
R.layout.departure_listing); R.layout.departure_listing);
if (savedInstanceState != null) { if (savedInstanceState != null) {
@ -115,6 +119,7 @@ public class ViewDeparturesActivity extends SherlockListActivity {
for (Parcelable departure : savedInstanceState for (Parcelable departure : savedInstanceState
.getParcelableArray("departures")) { .getParcelableArray("departures")) {
mDeparturesAdapter.add((Departure) departure); mDeparturesAdapter.add((Departure) departure);
mDeparturesAdapter.notifyDataSetChanged();
} }
} }
if (savedInstanceState.containsKey("boardedDeparture")) { if (savedInstanceState.containsKey("boardedDeparture")) {
@ -125,7 +130,8 @@ public class ViewDeparturesActivity extends SherlockListActivity {
mSelectedDeparture = (Departure) savedInstanceState mSelectedDeparture = (Departure) savedInstanceState
.getParcelable("selectedDeparture"); .getParcelable("selectedDeparture");
} }
if(savedInstanceState.getBoolean("hasActionMode") && mSelectedDeparture != null) { if (savedInstanceState.getBoolean("hasActionMode")
&& mSelectedDeparture != null) {
startDepartureActionMode(); startDepartureActionMode();
} }
} }
@ -218,6 +224,7 @@ public class ViewDeparturesActivity extends SherlockListActivity {
public void onResult(RealTimeDepartures result) { public void onResult(RealTimeDepartures result) {
mDepartureFetchIsPending = false; mDepartureFetchIsPending = false;
Log.i(Constants.TAG, "Processing data from server"); Log.i(Constants.TAG, "Processing data from server");
mProgress.setVisibility(View.INVISIBLE);
processLatestDepartures(result); processLatestDepartures(result);
Log.i(Constants.TAG, "Done processing data from server"); Log.i(Constants.TAG, "Done processing data from server");
} }
@ -229,12 +236,15 @@ public class ViewDeparturesActivity extends SherlockListActivity {
Toast.makeText(ViewDeparturesActivity.this, Toast.makeText(ViewDeparturesActivity.this,
R.string.could_not_connect, Toast.LENGTH_LONG).show(); R.string.could_not_connect, Toast.LENGTH_LONG).show();
mEmptyView.setText(R.string.could_not_connect); mEmptyView.setText(R.string.could_not_connect);
mProgress.setVisibility(View.INVISIBLE);
// Try again in 60s // Try again in 60s
scheduleDepartureFetch(60000); scheduleDepartureFetch(60000);
} }
}; };
Log.i(Constants.TAG, "Fetching data from server"); Log.i(Constants.TAG, "Fetching data from server");
mGetDeparturesTask.execute(new StationPair(mOrigin, mDestination)); mGetDeparturesTask.execute(new StationPair(mOrigin, mDestination));
mProgress.setVisibility(View.VISIBLE);
} }
private void fetchLatestSchedule() { private void fetchLatestSchedule() {
@ -264,6 +274,8 @@ public class ViewDeparturesActivity extends SherlockListActivity {
Toast.makeText(ViewDeparturesActivity.this, Toast.makeText(ViewDeparturesActivity.this,
R.string.could_not_connect, Toast.LENGTH_LONG).show(); R.string.could_not_connect, Toast.LENGTH_LONG).show();
mEmptyView.setText(R.string.could_not_connect); mEmptyView.setText(R.string.could_not_connect);
mProgress.setVisibility(View.GONE);
// Try again in 60s // Try again in 60s
scheduleScheduleInfoFetch(60000); scheduleScheduleInfoFetch(60000);
} }
@ -290,6 +302,7 @@ public class ViewDeparturesActivity extends SherlockListActivity {
if (result.getDepartures().isEmpty()) { if (result.getDepartures().isEmpty()) {
final TextView textView = mEmptyView; final TextView textView = mEmptyView;
textView.setText(R.string.no_data_message); textView.setText(R.string.no_data_message);
mProgress.setVisibility(View.GONE);
Linkify.addLinks(textView, Linkify.WEB_URLS); Linkify.addLinks(textView, Linkify.WEB_URLS);
return; return;
} }