package com.sheep.gamegroup.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sheep.gamegroup.model.entity.GridViewEntity;
import com.sheep.jiuyan.samllsheep.R;

import java.util.List;

/**
 * Created by ljy on 2018/5/7.
 */

public class AdpTrymakemoneyTabGridview extends BaseAdapter {
    private Context context;
    private List<Object> list;

    public AdpTrymakemoneyTabGridview(Context context, List<Object> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public GridViewEntity getItem(int position) {
        return (GridViewEntity) list.get(position);
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Object tag = convertView == null ? null : convertView.getTag();
        ViewHolder holder;
        if(tag instanceof ViewHolder){
            holder = (ViewHolder) tag;
        }else {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.withdrawal_gridview_item, null);
            holder.item_tv = convertView.findViewById(R.id.item_tv);

            convertView.setTag(holder);
        }

        if (getItem(position).isSelectState()){
            holder.item_tv.setTextColor(context.getResources().getColor(R.color.blue_end));
        }else{
            holder.item_tv.setTextColor(context.getResources().getColor(R.color.txt_black_818181));
        }
        holder.item_tv.setText(getItem(position).getName()+"");
        return convertView;
    }

    class ViewHolder{
        TextView item_tv;
    }
}
