--- a/src/com/beem/project/beem/ui/ContactList.java Mon May 24 20:44:56 2010 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Mon May 24 20:45:31 2010 +0200
@@ -551,25 +551,23 @@
public void onPresenceChanged(PresenceAdapter presence) throws RemoteException {
String from = presence.getFrom();
boolean resfound = false;
- for (Contact curContact : mListContact) {
- if (curContact.getJID().equals(StringUtils.parseBareAddress(from))) {
- String pres = StringUtils.parseResource(from);
- for (String res : curContact.getMRes()) {
- if (res.equals(pres)) {
- resfound = true;
- break;
- }
- }
- curContact.setStatus(mRoster.getPresence(StringUtils.parseBareAddress(presence.getFrom())));
- int status = presence.getStatus();
- if (!resfound && !Status.statusOnline(status))
- curContact.addRes(pres);
- else if (resfound && Status.statusOnline(status))
- curContact.delRes(pres);
- mHandler.post(new RunnableChange());
- return;
+ int foundIdx = 0;
+ boolean found = false;
+ Contact contact = mRoster.getContact(StringUtils.parseBareAddress(from));
+ for (int i = 0; i < mListContact.size(); i++) {
+ Contact curContact = mListContact.get(i);
+ if (curContact.getJID().equals(contact.getJID())) {
+ found = true;
+ foundIdx = i;
+ break;
}
}
+ if (found){
+ mListContact.set(foundIdx, contact);
+ } else {
+ mListContact.add(contact);
+ }
+ mHandler.post(new RunnableChange());
}
}