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

import java.util.List;

/**
 * 消防巡逻适配器
 */
public class XfxlAdapter extends BaseAdapter {

    private Context context;
    private List<DlbInfo> list;

    public XfxlAdapter(Context context, List<DlbInfo> 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.dlb_item, viewGroup,false);
            holder.tv_d = (TextView) view.findViewById(R.id.tv_d);
            holder.tv_xh = (TextView) view.findViewById(R.id.tv_xh);
            holder.tv_zt = (TextView) view.findViewById(R.id.tv_zt);
            view.setTag(holder);
            AutoUtils.autoSize(view);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tv_d.setText(list.get(i).getDian());
        holder.tv_xh.setText(list.get(i).getXh() + "号点");
        if (list.get(i).isStatu()) {
            holder.tv_zt.setText("已签到");
        } else {
            holder.tv_zt.setText("未签到");
        }
        return view;
    }

    static class ViewHolder {
        TextView tv_xh;
        TextView tv_d;
        TextView tv_zt;
    }
}
