package com.cooleshow.student.adapter;

import android.widget.ImageView;

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.student.R;
import com.cooleshow.student.bean.SelectMyGroupBean;
import com.cooleshow.student.bean.VideoCourseListBean;

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

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

    @Override
    protected void convert(@NonNull BaseViewHolder holder, SelectMyGroupBean.RowsBean data) {
        ImageView iv_bg = holder.getView(R.id.iv_bg);
        //封面
        GlideUtils.INSTANCE.loadImage(getContext(), data.lessonCoverUrl, iv_bg);
        //title
        holder.setText(R.id.tv_title, data.lessonName);
        //头像
        ImageView cir_avatar = holder.getView(R.id.cir_avatar);
        GlideUtils.INSTANCE.loadImage(getContext(), data.avatar, cir_avatar);
        //老师名称
        holder.setText(R.id.tv_author_name, data.username);
        //购买人数
        holder.setText(R.id.tv_buy_num, getContext().getString(R.string.pay_count_str, data.countStudent+""));
        //￥120/4课时
        String price = "￥" + data.lessonPrice + "/" + data.lessonCount + "课时";
        holder.setText(R.id.tv_price, price);
    }

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