package com.wd.workoffice.ui.adapter;


import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.ClientBean;
import com.wd.workoffice.util.UserKeeper;

import java.util.List;

/**
 * Created by flexible on 2018/8/13.
 */

public class WorkDepManageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    int type;// 0 红色 1 灰色
    boolean isManager;// 0 红色 1 灰色

    public WorkDepManageAdapter(int layoutResId, List data, int type, boolean isManager) {
        super(layoutResId, data);
        this.type = type;
        this.isManager = isManager;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        helper.setText(R.id.tv_name, item);
        if (isManager){
            helper.setVisible(R.id.tv_add,true);
            if (TextUtils.equals(item, UserKeeper.getInstance().getUserNickName())){
                helper.setVisible(R.id.tv_add,false);
            }
            if (type ==0){
                helper.setBackgroundRes(R.id.tv_add,R.drawable.shape_dialog_pro_ok);
                helper.setText(R.id.tv_add,"移除管理员");
                helper.setTextColor(R.id.tv_add,helper.itemView.getResources().getColor(R.color.red));
            }else {
                helper.setBackgroundRes(R.id.tv_add,R.drawable.shape_dialog_pro_cancel);
                helper.setText(R.id.tv_add,"设为管理员");
                helper.setTextColor(R.id.tv_add,helper.itemView.getResources().getColor(R.color.divider));
            }
        }else {
            helper.setVisible(R.id.tv_add,false);
        }
        helper.addOnClickListener(R.id.tv_add);
    }
}

