src/com/beem/project/beem/UIContactList.java
changeset 21 b9f4a0ef574a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/UIContactList.java	Thu Mar 19 22:27:28 2009 +0100
@@ -0,0 +1,81 @@
+package com.beem.project.beem;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.beem.project.beem.service.IXMPPFacade;
+
+import android.app.ExpandableListActivity;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.util.Log;
+import android.widget.ExpandableListAdapter;
+import android.widget.SimpleExpandableListAdapter;
+
+public class UIContactList extends ExpandableListActivity {
+
+    private IXMPPFacade mService = null;
+
+    @Override
+    public void onCreate(Bundle saveBundle) {
+        super.onCreate(saveBundle);
+        bindService(new Intent(this, BeemService.class), mConnection,
+                BIND_AUTO_CREATE | BIND_DEBUG_UNBIND);
+        showContactList();
+    }
+
+    private void showContactList() {
+        ExpandableListAdapter Adapter;
+        List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
+        List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
+
+        for (int i = 0; i < 2; i++) {
+            Map<String, String> curGroupMap = new HashMap<String, String>();
+            groupData.add(curGroupMap);
+            curGroupMap.put("NAME", "Group " + i);
+            
+            List<Map<String, String>> children = new ArrayList<Map<String, String>>();
+            for (int j = 0; j < 5; j++) {
+                Map<String, String> curChildMap = new HashMap<String, String>();
+                children.add(curChildMap);
+                curChildMap.put("NAME CHILD", "Child " + j);                
+            }
+            childData.add(children);
+        }
+
+        Adapter = new SimpleExpandableListAdapter(this, 
+                groupData, R.layout.contactlistgroup,
+                new String[] {"NAME"}, new int[] {R.id.textgroup},
+                childData, R.layout.contactlist,
+                new String[] {"NAME CHILD"}, new int[] {R.id.textchild});
+        setListAdapter(Adapter);
+    }
+
+    private ServiceConnection mConnection = new ServiceConnection() {
+        @Override
+        public void onServiceConnected(ComponentName name, IBinder service) {
+            mService = IXMPPFacade.Stub.asInterface(service);
+            /*
+             * mService.getGroupList(); mService.getContactList();
+             */
+            showContactList();
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName name) {
+        }
+
+    };
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        unbindService(mConnection);
+    }
+
+}