Android Open Source - SandB-Android Comment List Adapter






From Project

Back to project page SandB-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project SandB-Android 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 edu.grinnell.sandb;
/*from www.j a va2  s. co m*/
import java.util.List;

import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import edu.grinnell.sandb.comments.Comment;

/* List adapter to display the comments for a article */
public class CommentListAdapter extends ArrayAdapter<Comment> {
  private ArticleDetailActivity mActivity;
  private List<Comment> mData;

  public CommentListAdapter(ArticleDetailActivity a, int layoutId, List<Comment> data) {
    super(a, layoutId, data);
    mActivity = a;
    mData = data;
  }

  private class ViewHolder {
    TextView author;
    TextView body;
    TextView date;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder;

    if (convertView == null) {
      LayoutInflater li = mActivity.getLayoutInflater();
      convertView = li.inflate(R.layout.comments_row, parent, false);
      holder = new ViewHolder();
      holder.author = (TextView) convertView
          .findViewById(R.id.authorText);
      holder.body = (TextView) convertView
          .findViewById(R.id.descriptionText);
      holder.date = (TextView) convertView
          .findViewById(R.id.dateText);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    final Comment a = mData.get(position);
        
    if (a != null) {
      holder.author.setText(a.getAuthor());
      holder.body.setText(Html.fromHtml(a.getBody()));
      holder.date.setText(a.getPostDate());
    }
    
    return convertView;
  }
}




Java Source Code List

edu.grinnell.sandb.ArticleDetailActivity.java
edu.grinnell.sandb.ArticleDetailFragment.java
edu.grinnell.sandb.ArticleListAdapter.java
edu.grinnell.sandb.ArticleListFragment.java
edu.grinnell.sandb.CommentListAdapter.java
edu.grinnell.sandb.CommentListFragment.java
edu.grinnell.sandb.ImagePagerActivity.java
edu.grinnell.sandb.MainActivity.java
edu.grinnell.sandb.MainPrefs.java
edu.grinnell.sandb.ScarletAndBlackApplication.java
edu.grinnell.sandb.Utility.java
edu.grinnell.sandb.comments.CommentStorageHelper.java
edu.grinnell.sandb.comments.CommentTable.java
edu.grinnell.sandb.comments.Comment.java
edu.grinnell.sandb.data.ArticleStorageHelper.java
edu.grinnell.sandb.data.ArticleTable.java
edu.grinnell.sandb.data.Article.java
edu.grinnell.sandb.img.BodyImageGetter.java
edu.grinnell.sandb.img.ImageStorageHelper.java
edu.grinnell.sandb.img.ImageTable.java
edu.grinnell.sandb.img.Image.java
edu.grinnell.sandb.img.UniversalLoaderUtility.java
edu.grinnell.sandb.xmlpull.CommentParseTask.java
edu.grinnell.sandb.xmlpull.XmlCheckAgeTask.java
edu.grinnell.sandb.xmlpull.XmlFetchTask.java
edu.grinnell.sandb.xmlpull.XmlParseTask.java
edu.grinnell.sandb.xmlpull.XmlPullReceiver.java
edu.grinnell.sandb.xmlpull.XmlPullService.java