From 38c4c3bd032f128411882e810e59c516a4afef9a Mon Sep 17 00:00:00 2001 From: "dkeen@dkeen-laptop" Date: Mon, 13 Aug 2012 10:27:50 -0700 Subject: [PATCH] Added progress bar Changed manifest to allow SD card installations --- AndroidManifest.xml | 5 +- res/layout/departures.xml | 15 +++-- res/values/strings.xml | 62 ++++++++++--------- .../dougkeen/bart/ViewDeparturesActivity.java | 15 ++++- 4 files changed, 60 insertions(+), 37 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 534ab20..e25dc53 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,9 @@ + android:installLocation="auto" + android:versionCode="19" + android:versionName="2.0.1" > diff --git a/res/layout/departures.xml b/res/layout/departures.xml index 90f8e22..85f61b8 100644 --- a/res/layout/departures.xml +++ b/res/layout/departures.xml @@ -90,14 +90,21 @@ bart:tickInterval="5" /> - + - diff --git a/res/values/strings.xml b/res/values/strings.xml index ce12110..af471e9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,38 +1,40 @@ - BART Runner - Favorite routes - No favorite routes have been added yet - Add a route - Origin - Destination - Save - The origin and destination stations must be + + BART Runner + Favorite routes + No favorite routes have been added yet + Add a route + Origin + Destination + Save + The origin and destination stations must be different - You must select a destination station - You must select an origin station - Please wait while real time departure data is + You must select a destination station + You must select an origin station + Please wait while real time departure data is loaded - No departure data is currently available for this + 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/ - View - View departures - Missing departure? Inaccurate time? Please report to bartrunner@dougkeen.com - Delete - Yes - Cancel - View details on BART site - Could not connect to BART services. Please try + View + View departures + Missing/inaccurate departure? Feature request? Please report to bartrunner@dougkeen.com + Delete + Yes + Cancel + View details on BART site + Could not connect to BART services. Please try again later. - Also add return route - View system map - System map - Departures - OK - Quick departure lookup - I will board this train - Departure options - Your train - + Also add return route + View system map + System map + Departures + OK + Quick departure lookup + I will board this train + Departure options + Your train + + \ No newline at end of file diff --git a/src/com/dougkeen/bart/ViewDeparturesActivity.java b/src/com/dougkeen/bart/ViewDeparturesActivity.java index 7a6e3f4..96e5cba 100644 --- a/src/com/dougkeen/bart/ViewDeparturesActivity.java +++ b/src/com/dougkeen/bart/ViewDeparturesActivity.java @@ -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 mGetDeparturesTask; private AsyncTask 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; }