Android Open Source - RssReader Rss Items Adapter






From Project

Back to project page RssReader.

License

The source code is released under:

MIT License

If you think the Android project RssReader 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.vicmns.rssreader.adapters;
/*from   w ww .j  a  v a2 s .  com*/
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.vicmns.rssreader.R;
import com.vicmns.rssreader.models.RssItem;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
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 RssItemsAdapter extends BaseAdapter {  
  private Context context;
  private LayoutInflater mInflater;
  private List<RssItem> rssItemList;
  
  protected ImageLoader imageLoader = ImageLoader.getInstance();
  private DisplayImageOptions options;
  
  public RssItemsAdapter(Context context, List<RssItem> rssItemList) {
    this.context = context;
    this.rssItemList = rssItemList;
    this.mInflater = LayoutInflater.from(context);
    
    options = new DisplayImageOptions.Builder()
    .showImageOnLoading(R.color.grey)
    .showImageForEmptyUri(R.color.grey)
    .cacheInMemory(true)
    .cacheOnDisc(true)
    .considerExifParams(true)
    .bitmapConfig(Bitmap.Config.ARGB_8888)
    .build();
  }

  @Override
  public int getCount() {
    // TODO Auto-generated method stub
    return rssItemList.size();
  }

  @Override
  public Object getItem(int position) {
    return rssItemList.get(position);
  }

  @Override
  public long getItemId(int position) {
    return position;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if(convertView == null) {
      holder = new ViewHolder();
      convertView = mInflater.inflate(R.layout.rss_list_item, null);
      holder.rssItemImageIv = (ImageView) convertView.findViewById(R.id.rss_list_item_imageView);
      holder.rssItemTitleTv = (TextView) convertView.findViewById(R.id.rss_list_item_title_textView);
      holder.rssItemDateTv = (TextView) convertView.findViewById(R.id.rss_list_item_date_textView);
      
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    
    setListItemsViews(holder, position);
    
    return convertView;
  }
  
  private void setListItemsViews(ViewHolder holder, int position) {
    holder.rssItemTitleTv.setText(rssItemList.get(position).getTitle());
    
    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    holder.rssItemDateTv.setText(df.format(rssItemList.get(position).getPubDate()));
    
    Log.i(this.getClass().getSimpleName(), rssItemList.get(position).getImageURL());
    imageLoader.displayImage( rssItemList.get(position).getImageURL(), holder.rssItemImageIv, options);
  }
  
  private class ViewHolder {
    ImageView rssItemImageIv;
    TextView rssItemTitleTv;
    TextView rssItemDateTv;
  }

}




Java Source Code List

com.vicmns.rssreader.activities.MainActivity.java
com.vicmns.rssreader.activities.RssItemDetailsActivity.java
com.vicmns.rssreader.adapters.RssItemsAdapter.java
com.vicmns.rssreader.app.RssReaderApplication.java
com.vicmns.rssreader.http.GetRssItems.java
com.vicmns.rssreader.http.GetWidgetRssItems.java
com.vicmns.rssreader.http.SimpleXmlRequest.java
com.vicmns.rssreader.interfaces.GetRssItemsCallbacks.java
com.vicmns.rssreader.interfaces.HttpConsumerCallbacks.java
com.vicmns.rssreader.interfaces.ListOverlayLayoutCallbacks.java
com.vicmns.rssreader.models.RssItem.java
com.vicmns.rssreader.models.RssItems.java
com.vicmns.rssreader.services.GetRssItemsService.java
com.vicmns.rssreader.views.ListOverlayLayoutView.java
com.vicmns.rssreader.views.SquareImageView.java
com.vicmns.rssreader.widget.WidgetListProvider.java
com.vicmns.rssreader.widget.WidgetProvider.java
com.vicmns.rssreader.widget.WidgetService.java
fr.castorflex.android.smoothprogressbar.ColorsShape.java
fr.castorflex.android.smoothprogressbar.ContentLoadingSmoothProgressBar.java
fr.castorflex.android.smoothprogressbar.SmoothProgressBarUtils.java
fr.castorflex.android.smoothprogressbar.SmoothProgressBar.java
fr.castorflex.android.smoothprogressbar.SmoothProgressDrawable.java
org.robolectric.shadows.ShadowSupportMenuInflater.java