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"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dougkeen.bart"
android:versionCode="18"
android:versionName="2.0.0" >
android:installLocation="auto"
android:versionCode="19"
android:versionName="2.0.1" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

View File

@ -90,14 +90,21 @@
bart:tickInterval="5" />
</RelativeLayout>
<ListView
android:id="@android:id/list"
<ProgressBar
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_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@android:id/empty"
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />

View File

@ -1,38 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">BART Runner</string>
<string name="favorite_routes">Favorite routes</string>
<string name="empty_favorites_list_message">No favorite routes have been added yet</string>
<string name="add_route">Add a route</string>
<string name="origin">Origin</string>
<string name="destination">Destination</string>
<string name="save">Save</string>
<string name="error_matching_origin_and_destination">The origin and destination stations must be
<string name="app_name">BART Runner</string>
<string name="favorite_routes">Favorite routes</string>
<string name="empty_favorites_list_message">No favorite routes have been added yet</string>
<string name="add_route">Add a route</string>
<string name="origin">Origin</string>
<string name="destination">Destination</string>
<string name="save">Save</string>
<string name="error_matching_origin_and_destination">The origin and destination stations must be
different</string>
<string name="error_null_destination">You must select a destination station</string>
<string name="error_null_origin">You must select an origin station</string>
<string name="departure_wait_message">Please wait while real time departure data is
<string name="error_null_destination">You must select a destination station</string>
<string name="error_null_origin">You must select an origin station</string>
<string name="departure_wait_message">Please wait while real time departure data is
loaded</string>
<string name="no_data_message">No departure data is currently available for this
<string name="no_data_message">No departure data is currently available for this
route. Note that this route may require a non-standard transfer due to
a temporary change in service. Check for service advisories posted at
http://m.bart.gov/schedules/advisories/</string>
<string name="view">View</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="delete">Delete</string>
<string name="yes">Yes</string>
<string name="cancel">Cancel</string>
<string name="view_on_bart_site">View details on BART site</string>
<string name="could_not_connect">Could not connect to BART services. Please try
<string name="view">View</string>
<string name="view_departures">View departures</string>
<string name="missing_departure">Missing/inaccurate departure? Feature request? Please report to bartrunner@dougkeen.com</string>
<string name="delete">Delete</string>
<string name="yes">Yes</string>
<string name="cancel">Cancel</string>
<string name="view_on_bart_site">View details on BART site</string>
<string name="could_not_connect">Could not connect to BART services. Please try
again later.</string>
<string name="also_add_return_route">Also add return route</string>
<string name="view_system_map">View system map</string>
<string name="system_map">System map</string>
<string name="departures">Departures</string>
<string name="ok">OK</string>
<string name="quick_departure_lookup">Quick departure lookup</string>
<string name="getting_on_this_train">I will board this train</string>
<string name="departure_options">Departure options</string>
<string name="your_train">Your train</string>
<string name="also_add_return_route">Also add return route</string>
<string name="view_system_map">View system map</string>
<string name="system_map">System map</string>
<string name="departures">Departures</string>
<string name="ok">OK</string>
<string name="quick_departure_lookup">Quick departure lookup</string>
<string name="getting_on_this_train">I will board this train</string>
<string name="departure_options">Departure options</string>
<string name="your_train">Your train</string>
</resources>

View File

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