--- a/src/com/beem/project/beem/ui/ContactDialog.java Fri May 22 15:54:48 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialog.java Fri May 22 15:55:08 2009 +0200
@@ -6,6 +6,7 @@
import android.content.Intent;
import android.view.View;
import android.widget.Button;
+import android.widget.TextView;
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
@@ -15,12 +16,12 @@
private Contact mContact;
private Context mContext;
- public ContactDialog(final Context context, Contact c) {
+ public ContactDialog(final Context context, Contact curContact) {
super(context);
mContext = context;
setContentView(R.layout.contactdialog);
- mContact = c;
- setTitle(c.getJID());
+ mContact = curContact;
+ setTitle(curContact.getJID());
Button chat = (Button) findViewById(R.id.CDChat);
chat.setOnClickListener(new chatListener());
--- a/src/com/beem/project/beem/ui/ContactList.java Fri May 22 15:54:48 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Fri May 22 15:55:08 2009 +0200
@@ -65,31 +65,43 @@
mRosterListener = new BeemRosterListener();
mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
mBeemApplication = BeemApplication.getApplication(this);
-
- //TODO: a refaire
- /*if (mSettings.getString(getString(R.string.PreferenceHostKey), "").equals(""))
- startActivityForResult(new Intent(this, ContactListSettings.class), PREFERENCECHANGED);*/
- }
+ groupMap = new HashMap<String, List<Contact>>();
+ groupName = new ArrayList<String>();
+ mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
+ @Override
+ public void run() {
+ mService = mBeemApplication.getXmppFacade();
+ try {
+ mRoster = mService.getRoster();
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Get roster failed", e1);
+ }
+ if (mRoster != null) {
+ try {
+ mRoster.addConnectionListener(mRosterListener);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ callbackShowContactList();
+ }
+ });
+ }
@Override
- protected void onResume() {
- super.onResume();
-
- }
-
- @Override
- protected void onDestroy() {
- mBeemApplication.unbindBeemService();
- super.onDestroy();
- }
+ protected void onDestroy() {
+ mBeemApplication.unbindBeemService();
+ super.onDestroy();
+ }
private void callbackShowContactList() {
- if (mRoster != null)
+ if (mRoster != null) {
try {
buildContactList(mRoster.getContactList());
} catch (RemoteException e) {
e.printStackTrace();
}
+ }
}
/**
@@ -146,9 +158,7 @@
}
private void buildContactList(List<Contact> listContact) {
- mListContact = listContact;
- groupMap = new HashMap<String, List<Contact>>();
- groupName = new ArrayList<String>();
+ mListContact = listContact;
for (Contact contact : listContact) {
for (String group : contact.getGroups()) {
if (!groupMap.containsKey(group)) {
@@ -156,7 +166,8 @@
groupName.add(group);
}
try {
- groupMap.get(group).add(contact);
+ if (!groupMap.get(group).contains(contact))
+ groupMap.get(group).add(contact);
} catch (NullPointerException e) {
Log.e(TAG, "Failed to find group in groupMap", e);
}
@@ -214,7 +225,6 @@
}
void createDialog(Contact contact) {
-
Dialog dialogContact= new ContactDialog(ContactList.this, contact);
dialogContact.setOwnerActivity(ContactList.this);
dialogContact.show();