package com.cooleshow.teacher.adapter;

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

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.BaseLoadMoreModule;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.cooleshow.base.utils.GlideUtils;
import com.cooleshow.teacher.R;
import com.cooleshow.teacher.bean.SparringCourseListBean;
import com.cooleshow.teacher.constants.CourseConstants;

import androidx.annotation.NonNull;

/**
 * Author by pq, Date on 2022/4/25.
 */
public class SparringCourseListAdapter extends BaseQuickAdapter<SparringCourseListBean.RowsBean, BaseViewHolder> implements LoadMoreModule {

    public SparringCourseListAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, SparringCourseListBean.RowsBean data) {
        //时间
        holder.setText(R.id.tv_time, data.startTime);
        //title
        holder.setText(R.id.tv_title, data.userName);
        //subjectName
        holder.setText(R.id.tv_course_name, data.subjectName);
        ImageView iv_avatar = holder.getView(R.id.iv_avatar);
        //头像
        GlideUtils.INSTANCE.loadImage(getContext(), data.avatar, iv_avatar, R.drawable.icon_teacher_default_head);

        TextView tvCourseStatusBt = holder.getView(R.id.tv_course_status_bt);
        TextView tv_course_status = holder.getView(R.id.tv_course_status);

        if (TextUtils.equals(CourseConstants.COURSE_STATUS_NOT_START, data.status)) {
            //未开始
            tv_course_status.setText("未开始");
            tv_course_status.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_ff802c));
            tvCourseStatusBt.setText("调课");
            tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_normal);
            tvCourseStatusBt.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
        }

        if (TextUtils.equals(CourseConstants.COURSE_STATUS_ING, data.status)) {
            //进行中
            tv_course_status.setText("进行中");
            tv_course_status.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
            tvCourseStatusBt.setText("进入教室");
            tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_ing);
            tvCourseStatusBt.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.white));
        }

        if (TextUtils.equals(CourseConstants.COURSE_STATUS_COMPLETE, data.status)) {
            //已结束
            tv_course_status.setText("已结束");
            tv_course_status.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_999999));

            tvCourseStatusBt.setText("评价");
            tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_normal);
            tvCourseStatusBt.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
        }
    }

    @NonNull
    @Override
    public BaseLoadMoreModule addLoadMoreModule(@NonNull BaseQuickAdapter<?, ?> baseQuickAdapter) {
        return new BaseLoadMoreModule(baseQuickAdapter);
    }
}
