Defilement des boutons dans la banniere.
authorVincent Veronis <veroni_v@epitech.net>
Thu, 17 Sep 2009 19:10:55 +0200
changeset 372 0a00323e7e5b
parent 365 c90f06cae09e
child 373 da35534975cd
Defilement des boutons dans la banniere.
src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Sep 17 17:20:08 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Thu Sep 17 19:10:55 2009 +0200
@@ -154,13 +154,9 @@
 	@Override
 	public void onClick(View arg0) {
 	    mPosCurGroup--;
-	    if (mPosCurGroup < -1)
+	    if (mPosCurGroup < 0)
 		mPosCurGroup = mListGroup.size() - 1;
-	    Button b = (Button) findViewById(R.id.contactlist_group);
-	    if (mPosCurGroup == -1)
-		b.setText(R.string.contact_list_all_contact);
-	    else
-		b.setText(mListGroup.get(mPosCurGroup));
+	    buildBanner();
 	    try {
 		buildContactList(mRoster.getContactList(), mRoster.getGroupsNames());
 	    } catch (RemoteException e) {
@@ -191,11 +187,7 @@
 	    mPosCurGroup++;
 	    if (mPosCurGroup == mListGroup.size())
 		mPosCurGroup = -1;
-	    Button b = (Button) findViewById(R.id.contactlist_group);
-	    if (mPosCurGroup == -1)
-		b.setText(R.string.contact_list_all_contact);
-	    else
-		b.setText(mListGroup.get(mPosCurGroup));
+	    buildBanner();
 	    try {
 		buildContactList(mRoster.getContactList(), mRoster.getGroupsNames());
 	    } catch (RemoteException e) {
@@ -206,6 +198,33 @@
     }
 
     /**
+     * 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
@@ -289,9 +308,7 @@
 		}
 	    }
 	}
-
 	sortBeemContactList();
-
 	ListView listView = (ListView) findViewById(R.id.contactlist);
 	listView.setOnItemClickListener(new BeemContactListOnClick());
 	listView.setOnItemLongClickListener(new BeemContactListOnLongClick());
@@ -448,6 +465,7 @@
 	public BeemContactList(final Context context) {
 	    mInflater = LayoutInflater.from(context);
 	}
+
 	/**
 	 * {@inheritDoc}
 	 */
@@ -455,6 +473,7 @@
 	public int getCount() {
 	    return mListContact.size();
 	}
+
 	/**
 	 * {@inheritDoc}
 	 */
@@ -462,6 +481,7 @@
 	public Object getItem(int position) {
 	    return position;
 	}
+
 	/**
 	 * {@inheritDoc}
 	 */
@@ -469,6 +489,7 @@
 	public long getItemId(int position) {
 	    return position;
 	}
+
 	/**
 	 * {@inheritDoc}
 	 */