Tri de la contact list.
--- a/src/com/beem/project/beem/ui/ContactList.java Fri Sep 25 15:59:02 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Fri Sep 25 19:10:48 2009 +0200
@@ -1,6 +1,5 @@
package com.beem.project.beem.ui;
-import java.security.spec.MGF1ParameterSpec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -55,10 +54,11 @@
private static final String TAG = "CONTACTLIST_ACT";
private static final int REQUEST_CODE = 1;
- private BeemContactList mAdapter;
+ private BeemContactList mAdapterContactList;
+ private BeemBanner mAdapterBanner;
private IRoster mRoster;
private List<Contact> mListContact = new ArrayList<Contact>();
- private List<String> mListGroup;
+ private List<String> mListGroup = new ArrayList<String>();
private Map<String, List<Contact>> mContactOnGroup = new HashMap<String, List<Contact>>();
private String mCurGroup;
private Handler mHandler;
@@ -77,7 +77,8 @@
protected void onCreate(Bundle saveBundle) {
super.onCreate(saveBundle);
setContentView(R.layout.contactlist);
- mAdapter = new BeemContactList(this);
+ mAdapterContactList = new BeemContactList(this);
+ mAdapterBanner = new BeemBanner(this);
mHandler = new Handler();
mReceiver = new BeemBroadcastReceiver();
}
@@ -157,12 +158,6 @@
unbindService(mServConn);
}
- @Override
- public void onContentChanged() {
- super.onContentChanged();
- Log.i("OO", "CHANGED");
- }
-
/**
* Comparator Contact by Name.
*/
@@ -221,13 +216,13 @@
ListView listView = (ListView) findViewById(R.id.contactlist);
listView.setOnItemClickListener(new BeemContactListOnClick());
listView.setOnItemLongClickListener(new BeemContactListOnLongClick());
- listView.setAdapter(mAdapter);
+ listView.setAdapter(mAdapterContactList);
}
private void buildBanner() {
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setOnItemClickListener(new OnItemClickGroupName());
- g.setAdapter(new BeemBanner(this));
+ g.setAdapter(mAdapterBanner);
}
/**
@@ -324,7 +319,8 @@
@Override
public void run() {
sortBeemContactList();
- mAdapter.notifyDataSetChanged();
+ mAdapterContactList.notifyDataSetChanged();
+ mAdapterBanner.notifyDataSetChanged();
}
}
@@ -365,7 +361,7 @@
}
@Override
- public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
+ public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
List<Contact> tmpContactList = mContactOnGroup.get(group);
Contact curContact = null;
for (Contact c : tmpContactList) {
@@ -373,6 +369,11 @@
curContact = c;
tmpContactList.remove(c);
c.getGroups().remove(group);
+ if (mContactOnGroup.get(group).size() == 0) {
+ mContactOnGroup.remove(group);
+ mListGroup.remove(group);
+ mListContact = mContactOnGroup.get(getString(R.string.contact_list_all_contact));
+ }
break;
}
}
@@ -598,7 +599,10 @@
List<Contact> tmpContactList = mRoster.getContactList();
List<String> tmpGroupList = mRoster.getGroupsNames();
Collections.sort(tmpGroupList);
- mListGroup = tmpGroupList;
+ if (mListGroup.size() > 0)
+ mListGroup.clear();
+ mListGroup.add(getString(R.string.contact_list_all_contact));
+ mListGroup.addAll(tmpGroupList);
mListGroup.add(getString(R.string.contact_list_no_group));
if (tmpGroupList.size() > 0) {
List<Contact> tmpNoGroup = new ArrayList<Contact>();
@@ -613,11 +617,11 @@
mContactOnGroup.put(s, tmpList);
}
mContactOnGroup.put(getString(R.string.contact_list_no_group), tmpNoGroup);
- mCurGroup = tmpGroupList.get(0);
} else {
- mCurGroup = null;
- mListContact = tmpContactList;
+ mContactOnGroup.put(getString(R.string.contact_list_no_group), tmpContactList);
}
+ mContactOnGroup.put(getString(R.string.contact_list_all_contact), tmpContactList);
+ mCurGroup = getString(R.string.contact_list_all_contact);
buildBanner();
buildContactList();
}