Bug.
--- a/src/com/beem/project/beem/ui/ContactList.java Thu Sep 24 23:54:11 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Thu Sep 24 23:57:41 2009 +0200
@@ -1,7 +1,9 @@
package com.beem.project.beem.ui;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -54,12 +56,14 @@
private static final int REQUEST_CODE = 1;
private BeemContactList mAdapter;
private IRoster mRoster;
- private List<Contact> mListContact;
+ private List<Contact> mListContact = new ArrayList<Contact>();
private List<String> mListGroup;
- private Map<String, List<Contact>> mContactOnGroup;
+ private Map<String, List<Contact>> mContactOnGroup = new HashMap<String, List<Contact>>();
+ private String mCurGroup;
private Handler mHandler;
private IXmppFacade mXmppFacade;
private final ServiceConnection mServConn = new BeemServiceConnection();
+ private BroadcastReceiver mReceiver;
/**
* Constructor.
@@ -74,8 +78,19 @@
setContentView(R.layout.contactlist);
mAdapter = new BeemContactList(this);
mHandler = new Handler();
- this.registerReceiver(new BeemBroadcastReceiver(), new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ mReceiver = new BeemBroadcastReceiver();
+ }
+ @Override
+ protected void onResume() {
+ super.onResume();
+ this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ this.unregisterReceiver(mReceiver);
}
/**
@@ -191,23 +206,20 @@
* @param listContact Contact list.
* @param listGroup Group list.
*/
- private void buildContactList(List<Contact> listContact, List<String> listGroup) {
- mListGroup = listGroup;
- Collections.sort(mListGroup);
- if (mListContact != null)
- mListContact.clear();
- for (Contact c : listContact) {
- if (c.getGroups().contains(listGroup.get(0))) {
- mListContact.add(c);
- }
+ private void buildContactList() {
+
+ if (mCurGroup != null) {
+ mListContact = mContactOnGroup.get(mCurGroup);
}
- sortBeemContactList();
ListView listView = (ListView) findViewById(R.id.contactlist);
listView.setOnItemClickListener(new BeemContactListOnClick());
listView.setOnItemLongClickListener(new BeemContactListOnLongClick());
listView.setAdapter(mAdapter);
+ }
+
+ private void buildBanner() {
Gallery g = (Gallery) findViewById(R.id.gallery);
- g.setOnItemClickListener(new OnSelectedGroupName());
+ g.setOnItemClickListener(new OnItemClickGroupName());
g.setAdapter(new BeemBanner(this));
}
@@ -261,13 +273,13 @@
/**
* Event on middle groupe name.
*/
- private class OnSelectedGroupName implements OnItemClickListener {
+ private class OnItemClickGroupName implements OnItemClickListener {
@Override
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
- /*
- * TODO: Afficher la liste selon le group
- */
+ public void onItemClick(AdapterView<?> arg0, View v, int i, long l) {
+ buildContactList();
+ mCurGroup = mListGroup.get(i);
+ Log.i("OO", "!!");
}
}
@@ -347,22 +359,10 @@
}
@Override
-<<<<<<< local
public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
-=======
- public void onEntryDeleteFromGroup(String group, String jid)
- throws RemoteException {
->>>>>>> other
// TODO Auto-generated method stub
-<<<<<<< local
-=======
+ }
->>>>>>> other
- }
-<<<<<<< local
-
-=======
->>>>>>> other
/**
* {@inheritDoc}
*/
@@ -393,11 +393,6 @@
}
}
}
-<<<<<<< local
-=======
-
-
->>>>>>> other
}
/**
@@ -582,7 +577,27 @@
mRoster = mXmppFacade.getRoster();
if (mRoster != null) {
mRoster.addRosterListener(mBeemRosterListener);
- buildContactList(mRoster.getContactList(), mRoster.getGroupsNames());
+ List<Contact> tmpContactList = mRoster.getContactList();
+ List<String> tmpGroupList = mRoster.getGroupsNames();
+ Collections.sort(tmpGroupList);
+ mListGroup = tmpGroupList;
+ if (tmpGroupList.size() > 0) {
+ for (String s : tmpGroupList) {
+ List<Contact> tmpList = new ArrayList<Contact>();
+ for (Contact c : tmpContactList) {
+ if (c.getGroups().contains(s)) {
+ tmpList.add(c);
+ }
+ }
+ mContactOnGroup.put(s, tmpList);
+ }
+ mCurGroup = tmpGroupList.get(0);
+ } else {
+ mCurGroup = null;
+ mListContact = tmpContactList;
+ }
+ buildBanner();
+ buildContactList();
}
} catch (RemoteException e) {
e.printStackTrace();