src/com/beem/project/beem/service/RosterAdapter.java
changeset 759 5f7bbb0c2731
parent 756 c86eb188de1c
parent 747 22969380eb13
child 808 98d220b7fe9d
--- a/src/com/beem/project/beem/service/RosterAdapter.java	Sun May 30 23:18:46 2010 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java	Mon May 31 00:56:26 2010 +0200
@@ -112,20 +112,6 @@
 	    Log.e(TAG, "Error while adding new contact", e);
 	    return null;
 	}
-	if (groups != null) {
-	    for (String groupStr : groups) {
-		RosterGroup group = mAdaptee.getGroup(groupStr);
-		if (group == null) {
-		    group = mAdaptee.createGroup(groupStr);
-		}
-		try {
-		    group.addEntry(contact);
-		} catch (XMPPException e) {
-		    e.printStackTrace();
-		    return null;
-		}
-	    }
-	}
 	return getContactFromRosterEntry(contact);
     }
 
@@ -147,11 +133,8 @@
      */
     @Override
     public void createGroup(String groupname) throws RemoteException {
-	try {
+	if (mAdaptee.getGroup(groupname) == null)
 	    mAdaptee.createGroup(groupname);
-	} catch (IllegalArgumentException e) {
-	    Log.v(TAG, "Error while creating group", e);
-	}
     }
 
     /**
@@ -170,17 +153,10 @@
     @Override
     public List<Contact> getContactList() throws RemoteException {
 	boolean add = true;
-	List<Contact> coList = new ArrayList<Contact>(mAdaptee.getEntries().size());
-	for (RosterEntry entry : mAdaptee.getEntries()) {
-	    for (Contact c : coList) {
-		if (c.getJID().equals(entry.getUser())) {
-		    add = false;
-		    break;
-		}
-	    }
-	    // Because getEntries return duplicated user.
-	    if (add)
-		coList.add(getContactFromRosterEntry(entry));
+	Collection<RosterEntry> list = mAdaptee.getEntries();
+	List<Contact> coList = new ArrayList<Contact>(list.size());
+	for (RosterEntry entry : list) {
+	    coList.add(getContactFromRosterEntry(entry));
 	}
 	return coList;
     }