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.teacher.R;
import com.cooleshow.teacher.bean.MineLiveCourseListBean;

import java.util.List;

/**
 * 创建日期：2022/5/19 16:38
 *
 * @author Ryan
 * 类说明：
 */
public class MineLiveCourseAdapter extends BaseQuickAdapter<MineLiveCourseListBean.RowsBean, BaseViewHolder> implements LoadMoreModule {

    public MineLiveCourseAdapter() {
        super(R.layout.layout_mine_live_course_item);
    }


    @Override
    protected void convert(BaseViewHolder helper, MineLiveCourseListBean.RowsBean item) {
        if(item == null){
            return;
        }
        ImageView im_pic = helper.getView(R.id.im_pic);
        GlideUtils.INSTANCE.loadImage(getContext(), item.backgroundPic, im_pic);
        TextView tv_subject_name=helper.getView(R.id.tv_subject_name);
        tv_subject_name.setText(item.courseGroupName);
        ImageView im_header=helper.getView(R.id.im_header);
        GlideUtils.INSTANCE.loadImage(getContext(), item.avatar, im_header,R.drawable.icon_teacher_default_head);
        TextView tv_teacher_name=helper.getView(R.id.tv_teacher_name);
        tv_teacher_name.setText(item.teacherName);
        TextView tv_student_count=helper.getView(R.id.tv_student_count);
        tv_student_count.setText(item.studentCount+"人已购买");
        TextView tv_date=helper.getView(R.id.tv_date);
        tv_date.setText(TextUtils.isEmpty(item.courseStartTime)?"":TimeUtils.date2String(TimeUtils.string2Date(item.courseStartTime),"yyyy-MM-dd HH:mm"));
        TextView tv_price=helper.getView(R.id.tv_price);
        tv_price.setText("￥"+item.coursePrice+"/"+item.courseNum+"课时");
        helper.setText(R.id.subject_name,item.subjectName);
    }

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

}
