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.QdjuInfo;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * 签点记录适配器
 */
public class QdjlAdapter extends BaseAdapter {

    private Context context;
    private List<QdjuInfo> list;

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

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

    @Override
    public QdjuInfo 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) {
        QdjuInfo info;
        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.qdjl_item, viewGroup,false);
            holder.tv_qdjb = (TextView) view.findViewById(R.id.tv_qdjb);
            holder.tv_qdr = (TextView) view.findViewById(R.id.tv_qdr);
            holder.tv_xh = (TextView) view.findViewById(R.id.tv_xh);
            view.setTag(holder);
            AutoUtils.autoSize(view);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        info = getItem(i);
        holder.tv_qdjb.setText(info.getQdjb());
        holder.tv_xh.setText(info.getXh() + "");
        holder.tv_qdr.setText(info.getQdr());

        return view;
    }

    static class ViewHolder {
        TextView tv_xh;
        TextView tv_qdjb;
        TextView tv_qdr;
    }
}
