package org.arkiwi.app.adapter;

import java.util.ArrayList;

import org.arkiwi.app.R;
import org.arkiwi.app.feed.FeedQuery;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
 
public class AdapterList extends BaseAdapter {
 
    private Activity activity;
    private ArrayList<FeedQuery> fq;
    private static LayoutInflater inflater=null;
 
    public AdapterList(Activity a, ArrayList<FeedQuery> d) {
        activity = a;
        fq=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
 
    public int getCount() {
        return fq.size();
    }
 
    public Object getItem(int position) {
        return position;
    }
 
    public long getItemId(int position) {
        return position;
    }
 
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.archive_list_row, null);
 
        TextView title = (TextView)vi.findViewById(R.id.title); 
        TextView desc = (TextView)vi.findViewById(R.id.desc); 
        TextView datenews = (TextView)vi.findViewById(R.id.datenews);
 
        FeedQuery q = fq.get(position);
 
        title.setText(q.getTitle());
        desc.setText(q.getDesc());
        datenews.setText(q.getLast());
        return vi;
    }
}
