public void updateContactList(String email) { assert (email != null); if (email.equals(SynchronizedConnectionManager.getInstance().getUsernameEmail())) return; Presence presence = mConnectionManager.getPresence(email); if (presence == null) return; // if disconnection happened we might get null, and in such case this method execution // can stop int position = getContactPosition(email); Contact contact; if (position > -1) { contact = mContactsList.get(position); contact.update(presence); } else { contact = new Contact(presence); mContactsList.add(contact); } Collections.sort(mContactsList); // Log.i(TAG, "updateUI for: "+contact); }
public void updateContactList() { for (RosterEntry entry : mConnectionManager.getEntries()) { String email = entry.getUser(); if (!StringUtils.parseServer(email).equals(mConnectionManager.getDomain())) continue; if (email.equals(mConnectionManager.getUsernameEmail())) continue; Presence presence = mConnectionManager.getPresence(email); if (presence == null) return; // if disconnection happened we might get null, and in such case this method // execution can stop Contact contact; if (mContactsMap.containsKey(email)) { contact = mContactsList.get(getContactPosition(email)); contact.update(presence); } else { contact = new Contact(presence); contact.setName(entry.getName()); mContactsList.add(contact); mContactsMap.put(email, contact); } } Log.i(TAG, "updateContactList: " + mContactsList.toString()); Collections.sort(mContactsList); }