diff options
author | Andy Doan <andy.doan@linaro.org> | 2011-10-16 14:48:23 -0500 |
---|---|---|
committer | Andy Doan <doanac@gmail.com> | 2011-10-16 14:48:23 -0500 |
commit | 28203e12dbebd1b8ab350171b19f3c284434d256 (patch) | |
tree | 04f1d69b3cbf179f3ffc498ab956240355bdbd44 | |
parent | bbd3639ca0f1cd8cc4978ba938396899e889f8eb (diff) | |
download | LinaroConnect-28203e12dbebd1b8ab350171b19f3c284434d256.tar.gz |
move JSONLayoutAdapter to its activity
this is a small class and it makes the next commit easier
-rw-r--r-- | src/org/linaro/connect/JSONLayoutAdapter.java | 38 | ||||
-rw-r--r-- | src/org/linaro/connect/LinaroConnectActivity.java | 35 |
2 files changed, 35 insertions, 38 deletions
diff --git a/src/org/linaro/connect/JSONLayoutAdapter.java b/src/org/linaro/connect/JSONLayoutAdapter.java deleted file mode 100644 index b883fa7..0000000 --- a/src/org/linaro/connect/JSONLayoutAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.linaro.connect; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.content.Context; -import android.util.Log; - -public class JSONLayoutAdapter extends CachedJSONLayoutAdapter { - - private final static long INTERVAL = 1000*60*30; //check every 30 minutes - - private final static String LAYOUT_FILE = "connect-layout.json"; - private final static String LAYOUT_URL = "http://people.linaro.org/~doanac/connect-layout.json"; - - public JSONLayoutAdapter(Context ctx, int resId, int textViewResId) { - super(ctx, resId, textViewResId); - - setRefreshInterval(INTERVAL); - setCacheFileName(LAYOUT_FILE); - setJSONUrl(LAYOUT_URL); - setCacheResourceId(R.raw.connect_layout); - } - - @Override - protected void updateLayout(JSONObject jso) { - clear(); - try { - JSONArray links = jso.getJSONArray("links"); - for(int i = 0; i < links.length() && !links.isNull(i); i++) - add(new JSONLayoutItem(links.getJSONObject(i))); - } - catch(JSONException e) { - Log.e(LinaroConnect.TAG, "Error accessing JSON layout", e); - } - } -} diff --git a/src/org/linaro/connect/LinaroConnectActivity.java b/src/org/linaro/connect/LinaroConnectActivity.java index 0ba97e5..9dd5671 100644 --- a/src/org/linaro/connect/LinaroConnectActivity.java +++ b/src/org/linaro/connect/LinaroConnectActivity.java @@ -1,9 +1,14 @@ package org.linaro.connect; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -34,6 +39,36 @@ public class LinaroConnectActivity extends Activity { mAdapter.refresh(false); } + private class JSONLayoutAdapter extends CachedJSONLayoutAdapter { + + private final static long INTERVAL = 1000*60*30; //check every 30 minutes + + private final static String LAYOUT_FILE = "connect-layout.json"; + private final static String LAYOUT_URL = "http://people.linaro.org/~doanac/connect-layout.json"; + + public JSONLayoutAdapter(Context ctx, int resId, int textViewResId) { + super(ctx, resId, textViewResId); + + setRefreshInterval(INTERVAL); + setCacheFileName(LAYOUT_FILE); + setJSONUrl(LAYOUT_URL); + setCacheResourceId(R.raw.connect_layout); + } + + @Override + protected void updateLayout(JSONObject jso) { + clear(); + try { + JSONArray links = jso.getJSONArray("links"); + for(int i = 0; i < links.length() && !links.isNull(i); i++) + add(new JSONLayoutItem(links.getJSONObject(i))); + } + catch(JSONException e) { + Log.e(LinaroConnect.TAG, "Error accessing JSON layout", e); + } + } + } + private final OnItemClickListener mClickListener = new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int pos, long id) |