package com.cooleshow.teacher.adapter;

import android.text.TextUtils;
import android.view.View;
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.teacher.R;
import com.cooleshow.teacher.bean.MineLiveCourseListBean;
import com.cooleshow.teacher.bean.MineVideoCourseListBean;
import com.cooleshow.teacher.bean.VideoCourseListBean;

import java.util.List;

/**
 * 创建日期：2022/5/20 14:11
 *
 * @author Ryan
 * 类说明：
 */
public class MineVideoCourseAdapter extends BaseQuickAdapter<VideoCourseListBean.RowsBean, BaseViewHolder> implements LoadMoreModule {

    public MineVideoCourseAdapter() {
        super(R.layout.layout_mine_video_course_item);
    }


    @Override
    protected void convert(BaseViewHolder helper, VideoCourseListBean.RowsBean item) {
        if (item == null) {
            return;
        }
        helper.setText(R.id.course_name, item.lessonSubjectName);
        ImageView im_pic = helper.getView(R.id.im_pic);
        GlideUtils.INSTANCE.loadImage(getContext(), item.lessonCoverUrl, im_pic);
        TextView tv_title = helper.getView(R.id.tv_title);
        tv_title.setText(item.lessonName);
        ImageView im_header = helper.getView(R.id.im_header);
        GlideUtils.INSTANCE.loadImage(getContext(), item.avatar, im_header);
        TextView tv_teacher_name = helper.getView(R.id.tv_teacher_name);
        tv_teacher_name.setText(item.username);
        TextView tv_price = helper.getView(R.id.tv_price);
        String price = "￥" + item.lessonPrice + "/" + item.lessonCount + "课时";
        tv_price.setText(price);
        TextView tv_buy_num = helper.getView(R.id.tv_buy_num);
        if (TextUtils.equals(item.auditStatus, "PASS")) {
            tv_buy_num.setText(item.countStudent + "人已购买");
            tv_buy_num.setVisibility(View.VISIBLE);
        } else {
            tv_buy_num.setVisibility(View.GONE);
        }

    }

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

}
