diff --git a/.project b/.project index cdd9bf0..872fd55 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - DontMissTheBart + BARTRunner diff --git a/res/values/strings.xml b/res/values/strings.xml index b7db35b..e4e6cc8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,6 +1,6 @@ - BART Catcher + BART Runner Favorite Routes Press the menu button and select \"Add route\" to add a route diff --git a/src/com/dougkeen/bart/GetRealTimeDeparturesTask.java b/src/com/dougkeen/bart/GetRealTimeDeparturesTask.java index e7a5404..55f2b50 100644 --- a/src/com/dougkeen/bart/GetRealTimeDeparturesTask.java +++ b/src/com/dougkeen/bart/GetRealTimeDeparturesTask.java @@ -33,7 +33,7 @@ public abstract class GetRealTimeDeparturesTask private final static String API_KEY = "5LD9-IAYI-TRAT-MHHW"; private final static String API_URL = "http://api.bart.gov/api/etd.aspx?cmd=etd&key=" + API_KEY + "&orig=%1$s&dir=%2$s"; - private final static int MAX_ATTEMPTS = 3; + private final static int MAX_ATTEMPTS = 5; private Exception mException; @@ -93,9 +93,9 @@ public abstract class GetRealTimeDeparturesTask if (attemptNumber < MAX_ATTEMPTS - 1) { try { Log.w(Constants.TAG, - "Attempt to contact server failed... retrying in 5s", + "Attempt to contact server failed... retrying in 3s", e); - Thread.sleep(5000); + Thread.sleep(3000); } catch (InterruptedException interrupt) { // Ignore... just go on to next attempt } diff --git a/src/com/dougkeen/bart/ViewDeparturesActivity.java b/src/com/dougkeen/bart/ViewDeparturesActivity.java index 3b5cd3b..bd6c8a3 100644 --- a/src/com/dougkeen/bart/ViewDeparturesActivity.java +++ b/src/com/dougkeen/bart/ViewDeparturesActivity.java @@ -97,13 +97,23 @@ public class ViewDeparturesActivity extends ListActivity { setListAdapter(mDeparturesAdapter); } + @Override + protected void onPause() { + cancelDataFetch(); + super.onPause(); + } + @Override protected void onDestroy() { + cancelDataFetch(); + super.onDestroy(); + } + + private void cancelDataFetch() { if (mGetDeparturesTask != null) { mGetDeparturesTask.cancel(true); mDataFetchIsPending = false; } - super.onDestroy(); } @Override @@ -123,8 +133,8 @@ public class ViewDeparturesActivity extends ListActivity { if (!mDataFetchIsPending) { fetchLatestDepartures(); } - PowerManager powerManaer = (PowerManager) getSystemService(Context.POWER_SERVICE); - mWakeLock = powerManaer + PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); + mWakeLock = powerManager .newWakeLock( PowerManager.SCREEN_DIM_WAKE_LOCK, "ViewDeparturesActivity");