package com.pvy.colorPicker;

import java.util.ArrayList;

import com.pvy.colortester.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class recentsAdapter extends ArrayAdapter<Integer> {
	
	ArrayList<Integer> colors;
	
	public recentsAdapter(Context context, int textViewResourceId, ArrayList<Integer> objects) {
		super(context, textViewResourceId);
		colors = objects;
	}
	
	@Override
    public int getCount() {
        return colors.size();
    }

    @Override
    public long getItemId(int arg0) {
        return colors.get(arg0);
    }

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {		
        View v = convertView;
        
        if (v == null){
        	v = View.inflate(getContext(), R.layout.grid_item, null);
        }
        
        TextView name = (TextView) v.findViewById(R.id.text);
        LinearLayout color = (LinearLayout) v.findViewById(R.id.cols);
        color.setBackgroundColor(colors.get(position));
        name.setText("#" + Integer.toHexString(colors.get(position)).toUpperCase());
        
        return v;
	}

}
