Android Open Source - LheidoSMS-old Liste Conversations Adapter






From Project

Back to project page LheidoSMS-old.

License

The source code is released under:

GNU General Public License

If you think the Android project LheidoSMS-old listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lheido.sms;
//from www. ja va 2s  .c o  m
import java.util.ArrayList;

//import com.actionbarsherlock.app.ActionBar.LayoutParams;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListeConversationsAdapter extends BaseAdapter {
  /**
   * Rcuprer un item de la liste en fonction de sa position
   * @param position - Position de l'item  rcuprer
   * @return l'item rcupr
   */
  //private LayoutInflater mInflater;
  private ArrayList<LheidoContact> mListConv;
  private Context mContext;
  
  public ListeConversationsAdapter(Context context, int ressource, ArrayList<LheidoContact> list_conversation){
    mContext = context;
    mListConv = list_conversation;
    //mInflater = LayoutInflater.from(mContext);
  }
  
  public LheidoContact getItem(int position) {
    return mListConv.get(position);
  }

  /**
   * Rcuprer l'identifiant d'un item de la liste en fonction de sa position (plutt utilis dans le cas d'une
   * base de donnes, mais on va l'utiliser aussi)
   * @param position - Position de l'item  rcuprer
   * @return l'identifiant de l'item
   */
  public long getItemId(int position) {
    return position;
  }
  
  public View getView(int r, View convertView, ViewGroup parent) {
    LheidoContact contact = (LheidoContact) this.getItem(r);
     
    ListeConversationViewHolder holder; 
    if(convertView == null)
    {
      holder = new ListeConversationViewHolder();
      convertView = LayoutInflater.from(mContext).inflate(R.layout.conversations_list, parent, false);
      holder.mName = (TextView) convertView.findViewById(R.id.list_conversation_contact_name);
      holder.mCount = (TextView) convertView.findViewById(R.id.list_conversation_count);
      holder.mContactPicture = (ImageView) convertView.findViewById(R.id.contactPict);
      //holder.mLayout = (RelativeLayout) convertView.findViewById(R.id.message_relativeLayout);
      convertView.setTag(holder);
    }
    else
      holder = (ListeConversationViewHolder) convertView.getTag();
   
    holder.mName.setText(contact.getName());
    holder.mCount.setText(""+contact.getNb_sms());
    if(contact.getPic() != null){
      holder.mContactPicture.setImageBitmap(contact.getPic());
      //holder.mName.setBackgroundResource(R.drawable.bg_conversation_name);
      holder.mName.setBackgroundResource(android.R.color.transparent);
    } else{
      holder.mContactPicture.setImageResource(R.drawable.default_contact_photo);
      holder.mName.setBackgroundResource(android.R.color.transparent);
    }
    
    return convertView;
  }
  @Override
  public int getCount() {
    return mListConv.size();
  }
  static class ListeConversationViewHolder {
    //public RelativeLayout mLayout;
    public TextView mName;
    public TextView mCount;
    public ImageView mContactPicture;
  }
}




Java Source Code List

com.lheido.sms.ConversationAdapter.java
com.lheido.sms.ConversationMMSAdapter.java
com.lheido.sms.LheidoContact.java
com.lheido.sms.LheidoSMSFragBase.java
com.lheido.sms.LheidoSmsPreferenceActivity.java
com.lheido.sms.LheidoUtils.java
com.lheido.sms.ListeConversationsAdapter.java
com.lheido.sms.MMSFrag.java
com.lheido.sms.MainActivity.java
com.lheido.sms.Message.java
com.lheido.sms.SMSFrag.java
com.lheido.sms.SmsReceiver.java
com.lheido.sms.ViewPagerAdapter.java