package com.cooleshow.teacher.adapter;

import android.widget.ImageView;

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.VideoCourseListBean;

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 holder, VideoCourseListBean.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);
    }
}
