--- a/src/com/beem/project/beem/ui/ContactList.java Thu Sep 24 19:13:38 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Thu Sep 24 21:41:20 2009 +0200
@@ -3,6 +3,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Map;
import org.jivesoftware.smack.util.StringUtils;
@@ -25,7 +26,6 @@
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
-import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ListView;
@@ -40,7 +40,6 @@
import com.beem.project.beem.service.aidl.IBeemRosterListener;
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppFacade;
-import com.beem.project.beem.utils.PresenceType;
import com.beem.project.beem.utils.Status;
/**
@@ -54,7 +53,7 @@
private IRoster mRoster;
private List<Contact> mListContact;
private List<String> mListGroup;
- private int mPosCurGroup = -1;
+ private Map<String, List<Contact>> mContactOnGroup;
private Handler mHandler;
private IXmppFacade mXmppFacade;
private final ServiceConnection mServConn = new BeemServiceConnection();
@@ -120,98 +119,6 @@
}
/**
- * Event on middle groupe name.
- */
- private class OnClickGroupName implements View.OnClickListener {
- /**
- * Constructor.
- */
- public OnClickGroupName() {
-
- }
-
- @Override
- public void onClick(View arg0) {
-
- }
- }
-
- /**
- * Event on left groupe name.
- */
- private class OnClickLeft implements View.OnClickListener {
- /**
- * Constructor.
- */
- public OnClickLeft() {
-
- }
-
- @Override
- public void onClick(View arg0) {
- mPosCurGroup--;
- if (mPosCurGroup < 0)
- mPosCurGroup = mListGroup.size() - 1;
- buildBanner();
- try {
- buildContactList(mRoster.getContactList(), mRoster.getGroupsNames());
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- mAdapter.notifyDataSetChanged();
- mAdapter.notifyDataSetChanged();
- }
- }
-
- /**
- * Event on right groupe name.
- */
- private class OnClickRight implements View.OnClickListener {
-
- /**
- * Constructor.
- */
- public OnClickRight() {
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onClick(View v) {
- mPosCurGroup++;
- if (mPosCurGroup == mListGroup.size())
- mPosCurGroup = -1;
- buildBanner();
- try {
- buildContactList(mRoster.getContactList(), mRoster.getGroupsNames());
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- mAdapter.notifyDataSetChanged();
- }
- }
-
- /**
- * Build Banner button.
- */
- protected void buildBanner() {
- /*
- * Button bmid = (Button) findViewById(R.id.contactlist_group); Button bleft = (Button)
- * findViewById(R.id.contactlist_left); Button bright = (Button) findViewById(R.id.contactlist_right); if
- * (mPosCurGroup == -1) { bleft.setText(mListGroup.get(mListGroup.size() - 1));
- * bmid.setText(R.string.contact_list_all_contact); bright.setText(mListGroup.get(mPosCurGroup + 1)); } else if
- * (mPosCurGroup == 0) { bleft.setText(R.string.contact_list_all_contact);
- * bmid.setText(mListGroup.get(mPosCurGroup)); bright.setText(mListGroup.get(mPosCurGroup + 1)); } else if
- * (mPosCurGroup == mListGroup.size() -1 ) { bleft.setText(mListGroup.get(mPosCurGroup - 1));
- * bmid.setText(mListGroup.get(mPosCurGroup)); bmid.setText(R.string.contact_list_all_contact); } else {
- * bleft.setText(mListGroup.get(mPosCurGroup - 1)); bmid.setText(mListGroup.get(mPosCurGroup));
- * bright.setText(mListGroup.get(mPosCurGroup + 1)); }
- */
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -285,14 +192,9 @@
Collections.sort(mListGroup);
if (mListContact != null)
mListContact.clear();
- if (mPosCurGroup == -1)
- mListContact = listContact;
- else {
- String curGroup = mListGroup.get(mPosCurGroup);
- for (Contact c : listContact) {
- if (c.getGroups().contains(curGroup)) {
- mListContact.add(c);
- }
+ for (Contact c : listContact) {
+ if (c.getGroups().contains(listGroup.get(0))) {
+ mListContact.add(c);
}
}
sortBeemContactList();
@@ -301,8 +203,8 @@
listView.setOnItemLongClickListener(new BeemContactListOnLongClick());
listView.setAdapter(mAdapter);
Gallery g = (Gallery) findViewById(R.id.gallery);
- g.setAdapter(new ImageAdapter(this));
-
+ g.setOnItemClickListener(new OnSelectedGroupName());
+ g.setAdapter(new BeemBanner(this));
}
/**
@@ -353,6 +255,19 @@
}
/**
+ * Event on middle groupe name.
+ */
+ private class OnSelectedGroupName implements OnItemClickListener {
+
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+ /*
+ * TODO: Afficher la liste selon le group
+ */
+ }
+ }
+
+ /**
* Sort the contact list.
*/
private void sortBeemContactList() {
@@ -580,14 +495,14 @@
/**
* Adapter banner list.
*/
- public class ImageAdapter extends BaseAdapter {
+ public class BeemBanner extends BaseAdapter {
private Context mContext;
/**
* Constructor.
* @param c context activity.
*/
- public ImageAdapter(final Context c) {
+ public BeemBanner(final Context c) {
mContext = c;
}