Android Open Source - rss-parser R S S Item Adapter






From Project

Back to project page rss-parser.

License

The source code is released under:

Copyright (c) 2014 Artem Gapchenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the So...

If you think the Android project rss-parser 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 aga.rssparser.sample;
//from   w w w . j av a  2 s  . c  o m
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import java.text.SimpleDateFormat;

import aga.rssparser.model.RSSItem;

/**
 * @author artem
 * Created on 17.08.14.
 */
public class RSSItemAdapter extends ArrayAdapter<RSSItem> {
    private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    private final LayoutInflater mLayoutInflater;

    public RSSItemAdapter(Context context) {
        super(context, 0);

        mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final RSSItem item = getItem(position);

        final View root = convertView == null
                ? mLayoutInflater.inflate(R.layout.rss_item, parent, false)
                : convertView;

        ViewHolder holder = (ViewHolder) root.getTag();

        if (holder == null) {
            holder = new ViewHolder(root);
            root.setTag(holder);
        }

        holder.getTitle().setText(item.getTitle());
        holder.getLink().setText(item.getLink());

        holder.getPubDate().setText("Published " + FORMATTER.format(item.getPubDate()));

        return root;
    }
}




Java Source Code List

aga.rssparser.RSSReadException.java
aga.rssparser.RSSReader.java
aga.rssparser.Utils.java
aga.rssparser.model.Enclosure.java
aga.rssparser.model.FieldTypeAware.java
aga.rssparser.model.RSSChannel.java
aga.rssparser.model.RSSItem.java
aga.rssparser.sample.MainActivity.java
aga.rssparser.sample.RSSItemAdapter.java
aga.rssparser.sample.ViewHolder.java