package com.cooleshow.teacher.adapter;

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

import androidx.annotation.NonNull;

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.base.utils.TimeUtils;
import com.cooleshow.base.utils.UiUtils;
import com.cooleshow.teacher.R;
import com.cooleshow.teacher.bean.MineLiveCourseListBean;
import com.cooleshow.teacher.constants.CourseConstants;

/**
 * 创建日期：2022/6/17 15:45
 *
 * @author Ryan
 * 类说明：个人主页-直播课
 */
public class MineLiveCourseListAdapter extends BaseQuickAdapter<MineLiveCourseListBean.RowsBean, com.chad.library.adapter.base.viewholder.BaseViewHolder> implements LoadMoreModule {

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

    @Override
    protected void convert(@NonNull BaseViewHolder holder, MineLiveCourseListBean.RowsBean data) {
        if (data == null) {
            return;
        }
        //时间
        holder.setText(R.id.tv_time, TextUtils.isEmpty(data.courseStartTime) ? "" : TimeUtils.date2String(TimeUtils.string2Date(data.courseStartTime), "yyyy-MM-dd HH:mm"));
        //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);
        GlideUtils.INSTANCE.loadImage(getContext(), data.avatar, holder.getView(R.id.teacher_head), R.drawable.icon_teacher_default_head);
        holder.setText(R.id.teacher_name, data.teacherName);
        TextView tvCourseStatusBt = holder.getView(R.id.tv_course_status);
        tvCourseStatusBt.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
        tvCourseStatusBt.setText("￥"+data.coursePrice+"/"+data.courseNum+"课时");
    }

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