package com.common.im.adapter;

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.GroupApplyBean;
import com.common.im_ui.R;
import com.cooleshow.base.utils.GlideUtils;

import java.util.List;

import javax.microedition.khronos.opengles.GL;

/**
 * 创建日期：2022/6/13 17:20
 *
 * @author Ryan
 * 类说明：
 */
public class JoinGroupApplyAdapter extends BaseQuickAdapter<GroupApplyBean, BaseViewHolder> {

    public JoinGroupApplyAdapter(List<GroupApplyBean> data) {
        super(R.layout.layout_join_group_item, data);
    }

    private boolean isSelect;

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public boolean isSelect() {
        return isSelect;
    }

    @Override
    protected void convert(BaseViewHolder helper, GroupApplyBean item) {
        ImageView im_check = helper.getView(R.id.im_check);
        ImageView im_header = helper.getView(R.id.im_header);
        TextView tv_name = helper.getView(R.id.tv_name);
        TextView tv_content = helper.getView(R.id.tv_content);
        TextView tv_date = helper.getView(R.id.tv_date);
        if (isSelect) {
            im_check.setVisibility(View.VISIBLE);
            if (item.isSelect()) {
                im_check.setBackgroundResource(R.drawable.icon_item_select);
            } else {
                im_check.setBackgroundResource(R.drawable.icon_item_normal);
            }
        } else {
            im_check.setVisibility(View.GONE);
        }

        tv_name.setText(item.getUsername());
        GlideUtils.INSTANCE.loadImage(getContext(),item.getAvatar(),im_header,R.drawable.ic_stu_student_head);
        tv_content.setText(item.getDesc());
        tv_date.setText(item.getCreateTime());
    }

}