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.viewholder.BaseViewHolder;
import com.cooleshow.base.constanst.HomeWorkConstants;
import com.cooleshow.base.utils.GlideUtils;
import com.cooleshow.teacher.R;
import com.cooleshow.teacher.bean.PianoRoomCourseInfoBean;
import com.cooleshow.teacher.constants.CourseConstants;

import androidx.annotation.NonNull;

/**
 * Author by pq, Date on 2022/6/24.
 */
public class PianoRoomCourseStudentListAdapter extends BaseQuickAdapter<PianoRoomCourseInfoBean.StudentHomeworkListBean.RecordsBean, BaseViewHolder> {
    public static final int HOMEWORK_STATUS_IS_OK = 1;//已提交作业
    private int mDecorateHomework;

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

    @Override
    protected void convert(@NonNull BaseViewHolder holder, PianoRoomCourseInfoBean.StudentHomeworkListBean.RecordsBean data) {
        //头像
        ImageView iv_avatar = holder.getView(R.id.iv_avatar);
        GlideUtils.INSTANCE.loadImage(getContext(), data.studentAvatar, iv_avatar, R.drawable.icon_teacher_default_head);
        //名称
        holder.setText(R.id.tv_name, data.studentName);
        //subjectName
        if (TextUtils.isEmpty(data.subjectName)) {
            holder.setGone(R.id.tv_course_name, true);
        } else {
            holder.setVisible(R.id.tv_course_name, true);
            holder.setText(R.id.tv_course_name, data.subjectName);
        }
        TextView tv_submit_tip = holder.getView(R.id.tv_submit_tip);
        if (mDecorateHomework == CourseConstants.COURSE_HOMEWORK_SET) {
            //布置了作业
            tv_submit_tip.setVisibility(View.VISIBLE);
        } else {
            tv_submit_tip.setVisibility(View.GONE);
        }
        if (data.submitHomework == HOMEWORK_STATUS_IS_OK) {
            if (TextUtils.equals(data.homeworkStatus, HomeWorkConstants.COURSE_HOMEWORK_NOTREVIEW)) {
                tv_submit_tip.setText("未点评");
            } else {
                tv_submit_tip.setText("已点评");
            }
            tv_submit_tip.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_666666));
        } else {
            tv_submit_tip.setText("未提交");
            tv_submit_tip.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_999999));
        }
    }

    public void setHomeWordStatus(int decorateHomework) {
        mDecorateHomework = decorateHomework;
    }
}
