1 package com
.owncloud
.android
.extensions
;
3 import java
.util
.HashMap
;
4 import java
.util
.LinkedList
;
5 import java
.util
.Vector
;
7 import org
.apache
.commons
.httpclient
.HttpClient
;
8 import org
.apache
.commons
.httpclient
.methods
.GetMethod
;
9 import org
.json
.JSONArray
;
10 import org
.json
.JSONException
;
11 import org
.json
.JSONObject
;
13 import com
.owncloud
.android
.utils
.OwnCloudVersion
;
17 import android
.app
.Activity
;
18 import android
.app
.ListActivity
;
19 import android
.os
.Bundle
;
20 import android
.os
.Handler
;
21 import android
.util
.Log
;
22 import android
.widget
.SimpleAdapter
;
24 public class ExtensionsListActivity
extends ListActivity
{
26 private static final String packages_url
= "http://alefzero.eu/a/packages.php";
28 private Thread mGetterThread
;
29 private final Handler mHandler
= new Handler();
32 protected void onCreate(Bundle savedInstanceState
) {
33 super.onCreate(savedInstanceState
);
34 mGetterThread
= new Thread(new JsonGetter());
35 mGetterThread
.start();
38 public void done(JSONArray a
) {
39 LinkedList
<HashMap
<String
, String
>> ll
= new LinkedList
<HashMap
<String
, String
>>();
40 for (int i
= 0; i
< a
.length(); ++i
) {
42 ExtensionApplicationEntry ela
= new ExtensionApplicationEntry(
43 ((JSONObject
) a
.get(i
)));
44 HashMap
<String
, String
> ss
= new HashMap
<String
, String
>();
45 ss
.put("NAME", ela
.getName());
46 ss
.put("DESC", ela
.getDescription());
48 } catch (JSONException e
) {
52 setListAdapter(new SimpleAdapter(this, ll
, R
.layout
.simple_list_item_2
,
53 new String
[] { "NAME", "DESC" }, new int[] {
54 android
.R
.id
.text1
, android
.R
.id
.text2
}));
58 private class JsonGetter
implements Runnable
{
62 HttpClient hc
= new HttpClient();
63 GetMethod gm
= new GetMethod(packages_url
);
67 Log
.e("ASD", gm
.getResponseBodyAsString() + "");
68 ar
= new JSONObject(gm
.getResponseBodyAsString())
69 .getJSONArray("apps");
70 } catch (Exception e
) {
75 mHandler
.post(new Runnable() {
86 private class ExtensionApplicationEntry
{
87 private static final String APP_NAME
= "name";
88 private static final String APP_VERSION
= "version";
89 private static final String APP_DESC
= "description";
90 private static final String APP_ICON
= "icon";
91 private static final String APP_URL
= "download";
92 private static final String APP_PLAYID
= "play_id";
94 private String mName
, mDescription
, mIcon
, mDownload
, mPlayId
;
95 private OwnCloudVersion mVersion
;
97 public ExtensionApplicationEntry(JSONObject appentry
) {
99 mName
= appentry
.getString(APP_NAME
);
100 mDescription
= appentry
.getString(APP_DESC
);
101 mIcon
= appentry
.getString(APP_ICON
);
102 mDownload
= appentry
.getString(APP_URL
);
103 mPlayId
= appentry
.getString(APP_PLAYID
);
104 mVersion
= new OwnCloudVersion(appentry
.getString(APP_VERSION
));
105 } catch (JSONException e
) {
110 public String
getName() {
114 public String
getDescription() {
118 public String
getIcon() {
122 public String
getDownload() {
126 public String
getPlayId() {
130 public OwnCloudVersion
getVersion() {