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.ChoosePersonListBean;
import com.tenlionsoft.oamodule.beans.DeptBean;
import com.tenlionsoft.oamodule.holder.SelectedDeptHolder;

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

/**
 * 作者: adam
 * 日期: 2020/11/24 - 9:16 AM
 * 邮箱: itgaojian@163.com
 * 描述: 选中的人员
 */
public class SelectedPersonAdapter extends BaseRecyclerAdapter<ChoosePersonListBean, SelectedDeptHolder> {
    public List<DeptBean> mSelBeans = new ArrayList<>();

    public SelectedPersonAdapter(Context ctx, List<ChoosePersonListBean> list) {
        super(ctx, list);
    }

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

    @Override
    public void bindHolder(SelectedDeptHolder holder, int i) {
        ChoosePersonListBean bean = mData.get(i);
        holder.mTvName.setText(bean.getUserName());
        holder.mIvDel.setOnClickListener(v -> mOnDelListener.onDel(bean, i));
    }

    private OnDelListener mOnDelListener;

    public void addOnDelListener(OnDelListener listener) {
        this.mOnDelListener = listener;
    }

    public interface OnDelListener {
        void onDel(ChoosePersonListBean bean, int pos);
    }
}
