Android Open Source - TATupload Message Array Adapter






From Project

Back to project page TATupload.

License

The source code is released under:

GNU General Public License

If you think the Android project TATupload 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 uk.org.sucu.tatupload;
/*from   w  ww. j a va  2s.c o  m*/
import java.util.List;

import uk.org.sucu.tatupload.message.Text;
import uk.org.sucu.tatupload.parse.Parser;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MessageArrayAdapter extends ArrayAdapter<Text> {

  public static class ViewHolder {
    private TextView timeText;
    private TextView numberText;
    private TextView bodyText;
    private Text sms;
    
    public ViewHolder(TextView timeTV, TextView numberTV, TextView bodyTV){
      timeText = timeTV;
      numberText = numberTV;
      bodyText = bodyTV;
    }
    
    protected void setText(Text sms){
      this.sms = sms;
    }
    
    public Text getText(){
      return sms;
    }
  }
  
  public MessageArrayAdapter(Context context, int resource, List<Text> messages) {
    super(context, resource, messages);
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent){
    
    View content = convertView;
    ViewHolder holder;
    Text sms = getItem(position);
    
    if(content == null){
      //If there is no view, build it
      content = LayoutInflater.from(getContext()).inflate(R.layout.queued_sms_view , null);
      TextView bodyText = (TextView) content.findViewById(R.id.queued_sms_view_body);
      TextView numberText = (TextView) content.findViewById(R.id.queued_sms_view_number);
      TextView timeText = (TextView) content.findViewById(R.id.queued_sms_view_time);
      holder = new ViewHolder(timeText,numberText,bodyText);
      content.setTag(holder);
    } else {
      //If there is, get the pointers to its components
      holder = (ViewHolder) content.getTag();
    }
    
    holder.setText(sms);
    //set the text fields in the view based on its text message
    holder.bodyText.setText(sms.getBody());
    holder.numberText.setText(sms.getNumber());
    String time = Parser.timeStampToString(sms.getTimestamp());
    holder.timeText.setText(time);
    
    
    return content;
  }
  
  
}




Java Source Code List

org.apache.pig.impl.util.ObjectSerializer.java
uk.org.sucu.tatupload.BrowserAccessor.java
uk.org.sucu.tatupload.MessageArrayAdapter.java
uk.org.sucu.tatupload.NetCaller.java
uk.org.sucu.tatupload.Notifications.java
uk.org.sucu.tatupload.ParameterArrayAdapter.java
uk.org.sucu.tatupload.ResolveInfoArrayAdapter.java
uk.org.sucu.tatupload.Settings.java
uk.org.sucu.tatupload.TabContent.java
uk.org.sucu.tatupload.TabManager.java
uk.org.sucu.tatupload.TatUploadApplication.java
uk.org.sucu.tatupload.activity.MainActivity.java
uk.org.sucu.tatupload.activity.OptionActivity.java
uk.org.sucu.tatupload.activity.ParameterViewActivity.java
uk.org.sucu.tatupload.activity.SmsReviewActivity.java
uk.org.sucu.tatupload.activity.TutorialActivity.java
uk.org.sucu.tatupload.message.SmsList.java
uk.org.sucu.tatupload.message.SmsReceiver.java
uk.org.sucu.tatupload.message.Text.java
uk.org.sucu.tatupload.parse.Parameters.java
uk.org.sucu.tatupload.parse.Parser.java
uk.org.sucu.tatupload.parse.Property.java