package com.tenlionsoft.oamodule.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tenlionsoft.baselib.core.widget.base.BaseRecyclerAdapter;
import com.tenlionsoft.oamodule.R;
import com.tenlionsoft.oamodule.beans.SuperviseRelevanceOptionsListBean;
import com.tenlionsoft.oamodule.holder.RelevanceOptionsHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者: adam
 * 日期: 2022/4/18 - 16:35
 * 邮箱: itgaojian@163.com
 * 描述:
 */
public class RelevanceOptionsAdapter extends BaseRecyclerAdapter<SuperviseRelevanceOptionsListBean.RowsBean, RelevanceOptionsHolder> {
    public List<SuperviseRelevanceOptionsListBean.RowsBean> mSelBeans = new ArrayList<>();

    public RelevanceOptionsAdapter(Context ctx, List<SuperviseRelevanceOptionsListBean.RowsBean> list) {
        super(ctx, list);
    }

    @Override
    public RelevanceOptionsHolder createHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(mContext).inflate(R.layout.item_relevance_option, parent, false);
        return new RelevanceOptionsHolder(itemView);
    }

    @Override
    public void bindHolder(RelevanceOptionsHolder h, int i) {
        h.mTvName.setText(mData.get(i).getDataTitle());
        h.mTvUser.setText(mData.get(i).getDataUserName());
        h.mCbSel.setOnCheckedChangeListener(null);
        h.mCbSel.setChecked(mData.get(i).isCheck());
        h.mCbSel.setOnCheckedChangeListener((buttonView, isChecked) -> mLis.onItemCheckChange(mData.get(i), isChecked, i));
    }

    private OnItemCheckChange mLis;

    public void addOnItemCheckChange(OnItemCheckChange lis) {
        this.mLis = lis;
    }

    public interface OnItemCheckChange {
        void onItemCheckChange(SuperviseRelevanceOptionsListBean.RowsBean bean, boolean isCheck, int pos);
    }
}
