package com.cooleshow.student.adapter;

import android.text.TextUtils;
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.UiUtils;
import com.cooleshow.student.R;
import com.cooleshow.student.bean.PianoRoomCourseListBean;
import com.cooleshow.student.constants.CourseConstants;

/**
 * Author by pq, Date on 2022/4/25.
 */
public class PianoRoomCourseListAdapter extends BaseQuickAdapter<PianoRoomCourseListBean.RowsBean, BaseViewHolder> implements LoadMoreModule {

    public PianoRoomCourseListAdapter() {
        super(R.layout.item_piano_room_course_list_layout);
        addChildClickViewIds(R.id.iv_go_chat);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, PianoRoomCourseListBean.RowsBean data) {
        //时间
        holder.setText(R.id.tv_time, UiUtils.getCourseTimeString(data.startTime,data.endTime));
        //title
        holder.setText(R.id.tv_title, data.courseGroupName);
        //subjectName
        holder.setText(R.id.tv_course_name, data.subjectName);
        TextView tv_course_status = holder.getView(R.id.tv_course_status);

        if (TextUtils.equals(CourseConstants.COURSE_STATUS_NOT_START, data.status)) {
            //未开始
            tv_course_status.setText("未开始");
            tv_course_status.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_ff802c));
        }

        if (TextUtils.equals(CourseConstants.COURSE_STATUS_ING, data.status)) {
            //进行中
            tv_course_status.setText("进行中");
            tv_course_status.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
        }

        if (TextUtils.equals(CourseConstants.COURSE_STATUS_COMPLETE, data.status)) {
            //已结束
            tv_course_status.setText("已结束");
            tv_course_status.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_999999));
        }
    }

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