package com.cooleshow.teacher.adapter;

import android.text.TextUtils;
import android.view.View;
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.base.utils.UiUtils;
import com.cooleshow.teacher.R;
import com.cooleshow.teacher.bean.VideoCourseListBean;
import com.cooleshow.teacher.ui.course.MineVideoCourseActivity;
import com.cooleshow.usercenter.helper.UserHelper;

import androidx.annotation.NonNull;

/**
 * Author by pq, Date on 2022/4/26.
 */
public class VideoCourseListAdapter extends BaseQuickAdapter<VideoCourseListBean.RowsBean, BaseViewHolder> implements LoadMoreModule {

    public VideoCourseListAdapter() {
        super(R.layout.item_video_course_list_layout);
    }

    @Override
    protected void convert(@NonNull 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.loadTopRoundImage(getContext(), item.lessonCoverUrl, im_pic, 10, com.cooleshow.base.R.drawable.bg_video_placeholder);
        //课程名称
        TextView tv_title = helper.getView(R.id.tv_title);
        tv_title.setText(item.lessonName);
        //价格
        TextView tv_price = helper.getView(R.id.tv_price);
        tv_price.setText(UiUtils.getVideoCoursePriceText2(item.lessonPrice));
        TextView tv_price_unit = helper.getView(R.id.tv_price_unit);
        tv_price_unit.setText(String.format("/%d课时", item.lessonCount));
        //购买人数
        TextView tv_buy_num = helper.getView(R.id.tv_buy_num);
        tv_buy_num.setText(UiUtils.getBuyNumTip(item.lessonPrice, item.countStudent));
        //上架状态
        TextView tv_course_status_tip = helper.getView(R.id.tv_course_status_tip);
        tv_course_status_tip.setText("已上架");
        tv_course_status_tip.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
        tv_course_status_tip.setBackgroundResource(R.drawable.shape_d5fff7_9dp_right);
    }

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