# HG changeset patch # User marseille # Date 1240572412 -7200 # Node ID 0e59b0a9509b5ed410fa6871e9355e7a2b595063 # Parent f106a71a4cf6d587786d196d87a1f225d2eff8db# Parent 471893ecd4027b6eeb1c85fc4a71ae50c0ca3829 merge diff -r 471893ecd402 -r 0e59b0a9509b src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Fri Apr 24 13:21:23 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Fri Apr 24 13:26:52 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,19 +164,18 @@ 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 listGroup, List listContact) { - ExpandableListAdapter Adapter; List> groupData = new ArrayList>(); List>> childData = new ArrayList>>(); - - if (listGroup.size() == 0) + int groupSize = listGroup.size(); + if (groupSize == 0) listGroup.add("Default"); for (int i = 0; i < listGroup.size(); i++) { Map curGroupMap = new HashMap(); @@ -182,18 +186,20 @@ List> children = new ArrayList>(); for (int j = 0; j < listContact.size(); ++j) { Contact c = listContact.get(j); - Log.i(TAG, c.getID() + " " + c.getJID()); - Map curChildMap = new HashMap(); - children.add(curChildMap); - curChildMap.put(CHILD, c); + if (groupSize == 0 /* || listGroup.get(i).equals(c.getGroupName()) */) { + Log.i(TAG, c.getID() + " " + c.getJID()); + Map curChildMap = new HashMap(); + children.add(curChildMap); + curChildMap.put(CHILD, c); + } } 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); } /**