aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2011-10-16 14:44:52 -0500
committerAndy Doan <doanac@gmail.com>2011-10-16 14:44:52 -0500
commit937f02e4d314ccab04f3c36fa30085265bcba278 (patch)
treec3c94b9c05afcc124825fd5921cdd0cc5ee71a73
parent7331e625dc84ce4a400b976d646cd7c8fb558763 (diff)
downloadLinaroConnect-937f02e4d314ccab04f3c36fa30085265bcba278.tar.gz
add onBusy function to CachedLayout
this makes a more foolproof way to show the busy icon in the actual activities using this adapter
-rw-r--r--src/org/linaro/connect/CachedJSONLayoutAdapter.java10
-rw-r--r--src/org/linaro/connect/PostingsActivity.java7
2 files changed, 15 insertions, 2 deletions
diff --git a/src/org/linaro/connect/CachedJSONLayoutAdapter.java b/src/org/linaro/connect/CachedJSONLayoutAdapter.java
index 73c4ec6..bba57bd 100644
--- a/src/org/linaro/connect/CachedJSONLayoutAdapter.java
+++ b/src/org/linaro/connect/CachedJSONLayoutAdapter.java
@@ -48,7 +48,14 @@ public abstract class CachedJSONLayoutAdapter extends ArrayAdapter<JSONItem> {
mJSONUrl = url;
}
+ /**
+ * Called with true when a backround action is occurring.
+ */
+ protected void onBusy(boolean busy) {
+ }
+
void refresh(boolean force) {
+ onBusy(true);
JSONObject jso = getJSONObject();
updateLayout(jso);
@@ -56,6 +63,8 @@ public abstract class CachedJSONLayoutAdapter extends ArrayAdapter<JSONItem> {
if( force || now > mLastCheck + mInterval) {
new DownloadJSONTask().execute(mJSONUrl);
mLastCheck = now;
+ } else {
+ onBusy(false);
}
}
@@ -138,6 +147,7 @@ public abstract class CachedJSONLayoutAdapter extends ArrayAdapter<JSONItem> {
JSONObject jso = getJSONObject();
updateLayout(jso);
}
+ onBusy(false);
}
}
}
diff --git a/src/org/linaro/connect/PostingsActivity.java b/src/org/linaro/connect/PostingsActivity.java
index 0de0df8..79ae3a3 100644
--- a/src/org/linaro/connect/PostingsActivity.java
+++ b/src/org/linaro/connect/PostingsActivity.java
@@ -42,7 +42,6 @@ public class PostingsActivity extends Activity {
protected void onResume() {
super.onResume();
- setProgressBarIndeterminateVisibility(true);
mAdapter.refresh(false);
}
@@ -60,7 +59,6 @@ public class PostingsActivity extends Activity {
@Override
protected void updateLayout(JSONObject jso) {
clear();
- setProgressBarIndeterminateVisibility(false);
if(jso == null)
return;
@@ -83,6 +81,11 @@ public class PostingsActivity extends Activity {
tv.setText(jso.getSummary());
return v;
}
+
+ @Override
+ protected void onBusy(boolean busy) {
+ setProgressBarIndeterminateVisibility(busy);
+ }
}
private final OnItemClickListener mClickListener = new OnItemClickListener() {