package com.example.administrator.zhapp.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.example.administrator.zhapp.R;
import com.example.administrator.zhapp.entity.GzInfo;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * 工作适配器
 */
public class GzAdapter extends BaseAdapter {

    private Context context;
    private List<GzInfo> list;

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

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

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

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

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.gz_item,viewGroup, false);
            holder.tv_yjzj = (TextView) view.findViewById(R.id.tv_yjzj);
            holder.tv_qy = (TextView) view.findViewById(R.id.tv_qy);
            holder.tv_xh = (TextView) view.findViewById(R.id.tv_xh);
            view.setTag(holder);
            AutoUtils.autoSize(view);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tv_yjzj.setText(list.get(i).getYj() + "/" + list.get(i).getZj());
        holder.tv_qy.setText(list.get(i).getQy());
        holder.tv_xh.setText(list.get(i).getXh() + "");
        return view;
    }

    static class ViewHolder {
        TextView tv_xh;
        TextView tv_qy;
        TextView tv_yjzj;
    }
}
