Correction bug signal affiche.
authormarseille
Fri, 24 Apr 2009 13:26:01 +0200
changeset 174 f106a71a4cf6
parent 173 0ccad9608190
child 175 0e59b0a9509b
Correction bug signal affiche. Recuperation de la liste dans son etat initiale apres discution avec un contact
src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 24 13:02:27 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 24 13:26:01 2009 +0200
@@ -42,6 +42,7 @@
     private static final String CHILD = "CHILD";
     private static final String GROUP = "GROUP";
     private IXmppFacade mService = null;
+    private ExpandableListAdapter mAdapter;
     private BeemApplication mBeemApplication;
     private BeemRosterListener mRosterListener;
     private SharedPreferences mSettings;
@@ -63,6 +64,7 @@
 	super.onCreate(saveBundle);
 	mRosterListener = new BeemRosterListener();
 	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	mBeemApplication = BeemApplication.getApplication(this);
 	// bug fixe temporaire des betises de marseille
 	/*
 	 * SharedPreferences mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
@@ -74,9 +76,11 @@
     @Override
     protected void onResume() {
 	super.onResume();
-	mBeemApplication = BeemApplication.getApplication(this);
-	if (!mBeemApplication.isConnected())
+
+	if (!mBeemApplication.isConnected()) {
+	    mBeemApplication = BeemApplication.getApplication(this);
 	    mBeemApplication.startBeemService();
+	}
 	mBeemApplication.callWhenConnectedToServer(new Handler(), new Runnable() {
 	    @Override
 	    public void run() {
@@ -93,7 +97,8 @@
 			e.printStackTrace();
 		    }
 		}
-		callbackShowContactList();
+		if (mAdapter == null)
+		    callbackShowContactList();
 	    }
 	});
     }
@@ -159,15 +164,14 @@
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 	if (requestCode == PREFERENCECHANGED) {
 	    if (resultCode == RESULT_OK) {
-		setListAdapter(null);
+		mAdapter = null;
+		setListAdapter(mAdapter);
 		mBeemApplication.stopBeemService();
-		mBeemApplication.startBeemService();
 	    }
 	}
     }
 
     private void showContactList(List<String> listGroup, List<Contact> listContact) {
-	ExpandableListAdapter Adapter;
 	List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
 	List<List<Map<String, Contact>>> childData = new ArrayList<List<Map<String, Contact>>>();
 	int groupSize = listGroup.size();
@@ -182,7 +186,7 @@
 	    List<Map<String, Contact>> children = new ArrayList<Map<String, Contact>>();
 	    for (int j = 0; j < listContact.size(); ++j) {
 		Contact c = listContact.get(j);
-		if (groupSize == 0 || listGroup.get(i).equals(c.getGroupName())) {
+		if (groupSize == 0 /* || listGroup.get(i).equals(c.getGroupName()) */) {
 		    Log.i(TAG, c.getID() + " " + c.getJID());
 		    Map<String, Contact> curChildMap = new HashMap<String, Contact>();
 		    children.add(curChildMap);
@@ -192,10 +196,10 @@
 	    childData.add(children);
 	}
 
-	Adapter = new ContactExpandableListAdapter(this, groupData, R.layout.contactlistgroup, new String[] { GROUP },
+	mAdapter = new ContactExpandableListAdapter(this, groupData, R.layout.contactlistgroup, new String[] { GROUP },
 	    new int[] { R.id.textgroup }, childData, R.layout.contactlistcontact, new String[] { CHILD }, new int[] {
 		R.id.contactliststatus, R.id.contactlistpseudo, R.id.contactlistmsgperso, R.id.contactlistavatar });
-	setListAdapter(Adapter);
+	setListAdapter(mAdapter);
     }
 
     /**