package com.dahe.mylibrary.adapter;

import android.widget.CheckBox;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dahe.mylibrary.R;
import com.dahe.mylibrary.bean.NodeBean;
import com.dahe.mylibrary.utils.StringUtils;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class NodeAdapter extends BaseQuickAdapter<NodeBean, BaseViewHolder> {

    public NodeAdapter(int layoutResId, @Nullable List<NodeBean> data) {
        super(R.layout.item_node_select, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder helper, NodeBean item) {
        helper.setText(R.id.tv_title, item.getNode())
                .setText(R.id.tv_lxr, StringUtils.isEmpty(item.getDocking())?"":item.getDocking() + "  " + (StringUtils.isEmpty(item.getDockingPhone())?"":item.getDockingPhone()))
                .setText(R.id.tv_addres, item.getFreighter());
        CheckBox cb = helper.getView(R.id.cb);
        cb.setChecked("1".equals(item.isSelect())?true:false);
    }
}
