# HG changeset patch # User Vincent Veronis # Date 1253212749 -7200 # Node ID da35534975cd14c79fe3ac67110c8d7b21f41ea5 # Parent 0a00323e7e5bc8fa80a1baac74ce2baefebbab6a Modification de la banner. Mise en place d'un adapter pour avoir un effet de liste horizontale. diff -r 0a00323e7e5b -r da35534975cd res/layout/contactlist.xml --- a/res/layout/contactlist.xml Thu Sep 17 19:10:55 2009 +0200 +++ b/res/layout/contactlist.xml Thu Sep 17 20:39:09 2009 +0200 @@ -3,21 +3,9 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> - - - - - + diff -r 0a00323e7e5b -r da35534975cd src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Thu Sep 17 19:10:55 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Thu Sep 17 20:39:09 2009 +0200 @@ -26,6 +26,7 @@ import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Button; +import android.widget.Gallery; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -64,6 +65,15 @@ } + @Override + protected void onCreate(Bundle saveBundle) { + super.onCreate(saveBundle); + setContentView(R.layout.contactlist); + mAdapter = new BeemContactList(this); + mHandler = new Handler(); + + } + /** * Callback for menu creation. * @param menu the menu created @@ -108,21 +118,6 @@ } } - @Override - protected void onCreate(Bundle saveBundle) { - super.onCreate(saveBundle); - setContentView(R.layout.contactlist); - mAdapter = new BeemContactList(this); - Button b = (Button) findViewById(R.id.contactlist_group); - b.setOnClickListener(new OnClickGroupName()); - b = (Button) findViewById(R.id.contactlist_left); - b.setOnClickListener(new OnClickLeft()); - b = (Button) findViewById(R.id.contactlist_right); - b.setOnClickListener(new OnClickRight()); - mHandler = new Handler(); - - } - /** * Event on middle groupe name. */ @@ -201,27 +196,18 @@ * 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)); - } + /* + * 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)); } + */ } /** @@ -313,6 +299,9 @@ listView.setOnItemClickListener(new BeemContactListOnClick()); listView.setOnItemLongClickListener(new BeemContactListOnLongClick()); listView.setAdapter(mAdapter); + Gallery g = (Gallery) findViewById(R.id.gallery); + g.setAdapter(new ImageAdapter(this)); + } /** @@ -566,6 +555,56 @@ } /** + * Adapter banner list. + */ + public class ImageAdapter extends BaseAdapter { + private Context mContext; + + /** + * Constructor. + * @param c context activity. + */ + public ImageAdapter(final Context c) { + mContext = c; + } + + /** + * {@inheritDoc} + */ + @Override + public int getCount() { + return mListGroup.size(); + } + + /** + * {@inheritDoc} + */ + @Override + public Object getItem(int position) { + return position; + } + + /** + * {@inheritDoc} + */ + @Override + public long getItemId(int position) { + return position; + } + + /** + * {@inheritDoc} + */ + @Override + public View getView(int position, View convertView, ViewGroup parent) { + TextView i = new TextView(mContext); + i.setText(mListGroup.get(position)); + return i; + } + + } + + /** * The service connection used to connect to the Beem service. */ private class BeemServiceConnection implements ServiceConnection {