fix a NullException bug in the contact List
authorDa Risk <darisk972@gmail.com>
Sun, 30 May 2010 23:18:46 +0200
changeset 758 565942fdf426
parent 757 1a5cb28a1c4d
child 759 5f7bbb0c2731
fix a NullException bug in the contact List
src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu May 27 01:41:27 2010 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Sun May 30 23:18:46 2010 +0200
@@ -50,7 +50,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 import java.util.Iterator;
 
 import org.jivesoftware.smack.util.StringUtils;
@@ -62,7 +61,6 @@
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.content.SharedPreferences;
-import android.content.Context;
 import android.graphics.drawable.LevelListDrawable;
 import android.os.Bundle;
 import android.os.Handler;
@@ -738,6 +736,9 @@
 	mContactOnGroup.clear();
 	List<Contact> all = new LinkedList<Contact>();
 	List<Contact> noGroups = new LinkedList<Contact>();
+	for (String group: groupNames) {
+	    mContactOnGroup.put(group, new LinkedList<Contact>());
+	}
 	for (Contact c : contacts) {
 	    if (hideDisconnected && !Status.statusOnline(c.getStatus())) {
 		continue;
@@ -749,10 +750,6 @@
 	    else {
 		for (String currentGroup : groups) {
 		    List<Contact> contactsByGroups = mContactOnGroup.get(currentGroup);
-		    if (contactsByGroups == null) {
-			contactsByGroups = new LinkedList<Contact>();
-			mContactOnGroup.put(currentGroup, contactsByGroups);
-		    }
 		    contactsByGroups.add(c);
 		}
 	    }