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.LiveCourseListBean;
import com.cooleshow.teacher.constants.CourseConstants;

import androidx.annotation.NonNull;

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

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

    @Override
    protected void convert(@NonNull BaseViewHolder holder, LiveCourseListBean.RowsBean data) {
        //时间
        holder.setText(R.id.tv_time, data.startTime);
        //title
        holder.setText(R.id.tv_title, data.courseGroupName);
        //subjectName
        holder.setText(R.id.tv_course_name, data.subjectName);
        //购买人数
        holder.setText(R.id.tv_buy_num, getContext().getString(R.string.pay_count_str, data.studentCount));
        //头像
        ImageView iv_avatar = holder.getView(R.id.iv_bg);
        GlideUtils.INSTANCE.loadImage(getContext(), data.backgroundPic, iv_avatar, R.drawable.icon_teacher_default_head);

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

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

        if (TextUtils.equals(CourseConstants.COURSE_STATUS_ING, data.status)) {
            //进行中
            holder.setText(R.id.tv_course_status, "进行中");
            tvCourseStatusBt.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
        }

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

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