package com.common.im.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.common.im.bean.GroupMemberBean;
import com.common.im_ui.R;
import com.cooleshow.base.utils.GlideUtils;

import java.util.List;

/**
 * 创建日期：2022/6/13 15:54
 *
 * @author Ryan
 * 类说明：
 */
public class GroupMemberAdapter extends BaseQuickAdapter<GroupMemberBean, BaseViewHolder> {

    public GroupMemberAdapter(List<GroupMemberBean> data) {
        super(R.layout.group_member_list_item, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, GroupMemberBean bean) {

        ImageView ivIcon=helper.getView(R.id.iv_icon);
        TextView tvTitle=helper.getView(R.id.tv_title);
        TextView tvType=helper.getView(R.id.tv_type);
        View viewLine=helper.getView(R.id.view_line);
       int position= getItemPosition(bean);
        if (position == getItemCount() - 1 || !bean.getSuspensionTag().equals(getData().get(position + 1).getSuspensionTag())) {
            viewLine.setVisibility(View.INVISIBLE);
        } else {
            viewLine.setVisibility(View.VISIBLE);
        }

        if (null != bean) {
            String title = bean.getRoleType();
            GlideUtils.INSTANCE.loadImage(getContext(),bean.getAvatar(),ivIcon);
            tvTitle.setText(bean.getNickname());
            if (!TextUtils.isEmpty(title) && "乐团主管".equals(title)) {
                tvType.setText(title);
                tvType.setBackgroundResource(com.cooleshow.base.R.drawable.bg_group_member_item_yelloy);
            } else if (!TextUtils.isEmpty(title) && "运营主管".equals(title)) {
                tvType.setText(title);
                tvType.setBackgroundResource(com.cooleshow.base.R.drawable.bg_group_member_item_green);
            } else if (!TextUtils.isEmpty(title) && "乐队指导".equals(title)) {
                tvType.setText(title);
                tvType.setBackgroundResource(com.cooleshow.base.R.drawable.bg_group_member_item_blue);
            } else if (!TextUtils.isEmpty(title) && "指导老师".equals(title)) {
                tvType.setText(title);
                tvType.setBackgroundResource(com.cooleshow.base.R.drawable.bg_group_member_item_light_blue);
            } else if (!TextUtils.isEmpty(title) && "衔接老师".equals(title)) {
                tvType.setText(title);
                tvType.setBackgroundResource(com.cooleshow.base.R.drawable.bg_group_member_item_red_fc9);
            } else if (!TextUtils.isEmpty(title)) {
                tvType.setText(title);
                tvType.setBackground(null);
            } else {
                tvType.setVisibility(View.GONE);
            }
        }


    }

}
