package com.dahe.mylibrary.adapter;

import android.widget.TextView;

import androidx.annotation.Nullable;

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.StateBean;

import java.util.List;

public class CenterSimAdapter extends BaseQuickAdapter<StateBean, BaseViewHolder> {
    private StateBean selectString=null;


    public CenterSimAdapter(int layoutResId, @Nullable List<StateBean> data, StateBean selectString) {
        super(R.layout.item_select, data);
        this.selectString = selectString;
    }

    @Override
    protected void convert(BaseViewHolder helper, StateBean item) {
        helper.setText(R.id.tv_content,item.getDictLabel());
        TextView tv = helper.getView(R.id.tv_content);
        if (selectString!=null&&item.getDictValue()!=null){
            if (item.getDictValue().equals(selectString.getDictValue())){
                tv.setSelected(true);
            }else{
                tv.setSelected(false);
            }
        }


    }

    public void setSelect(StateBean selectString){
        this.selectString = selectString;
    }
}
