package com.bjzc.bhzhgd.adapter;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import com.bjzc.bhzhgd.R;
import com.bjzc.bhzhgd.bean.DeviceTreeBean;
import java.util.List;


/**
 * Created by ruihong on 2017/12/28.
 */


public class DeviceTreeAdapterBase extends CommonAdapter<DeviceTreeBean.DataBean>{
    private List<DeviceTreeBean.DataBean> datas;


    public DeviceTreeAdapterBase(Context context, List<DeviceTreeBean.DataBean> datas) {
        super(context, R.layout.item_device_tree, datas);
        this.datas = datas;

    }

    @Override
    protected void convert(ViewHolder viewHolder, DeviceTreeBean.DataBean item, int position) {
        CheckBox cb = viewHolder.getView(R.id.cb);
        TextView tv_smmc = viewHolder.getView(R.id.tv_smmc);
        ImageView iv_subDevice = viewHolder.getView(R.id.subDevice);

        cb.setChecked(item.isSelected());
        if(item.getISLEAF().equals("1")){
            iv_subDevice.setVisibility(View.GONE);
            cb.setVisibility(View.GONE);
        }else{
            iv_subDevice.setVisibility(View.VISIBLE);
            cb.setVisibility(View.GONE);
        }
        tv_smmc.setText("["+datas.get(position).getID()+"]" + "-" +"[" +datas.get(position).getNNAME()+"]");
    }
}
