package com.cooleshow.teacher.adapter;

import android.view.View;
import android.widget.ImageView;
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.TimeUtils;
import com.cooleshow.teacher.R;
import com.cooleshow.teacher.bean.SystemMessageBean;

import java.util.List;

/**
 * 创建日期：2022/5/24 13:50
 *
 * @author Ryan
 * 类说明：
 */
public class MessageBoxAdapter extends BaseQuickAdapter<SystemMessageBean.RowsBean, BaseViewHolder> implements LoadMoreModule {

    public MessageBoxAdapter() {
        super(R.layout.layout_message_nox_item);
    }


    @Override
    protected void convert(BaseViewHolder helper, SystemMessageBean.RowsBean item) {
        ImageView im_type = helper.getView(R.id.im_type);
        TextView tv_title = helper.getView(R.id.tv_title);
        tv_title.setText(item.title);
        TextView tv_content = helper.getView(R.id.tv_content);
        tv_content.setText(item.content);
        TextView tv_date = helper.getView(R.id.tv_date);
        tv_date.setText(TimeUtils.date2String(TimeUtils.string2Date(item.sendTime), "yyyy-MM-dd"));
        View view_unread = helper.getView(R.id.view_unread);
        if (item.readStatus == 0) {
            view_unread.setVisibility(View.VISIBLE);
        } else {
            view_unread.setVisibility(View.GONE);
        }
        switch (item.subType) {
            case "TEACHER_AUTH":
                //达人认证
                im_type.setBackgroundResource(R.drawable.icon_message_teacher_auth);
                break;
            case "MUSICIAN_AUTH":
                //音乐人认证
                im_type.setBackgroundResource(R.drawable.icon_message_music_auth);
                break;
            case "PRACTICE":
                //陪练课
                im_type.setBackgroundResource(R.drawable.icon_message_practice);
                break;
            case "LIVE":
                //直播课
                im_type.setBackgroundResource(R.drawable.icon_message_live);
                break;
            case "VIDEO":
                //视频课
                im_type.setBackgroundResource(R.drawable.icon_message_video);
                break;
            case "MUSIC_SHEET":
                //乐谱
                im_type.setBackgroundResource(R.drawable.icon_message_music_sheet);
                break;
            case "COURSE":
                //课程
                im_type.setBackgroundResource(R.drawable.icon_message_course);
                break;
            case "INCOME":
                //收入
                im_type.setBackgroundResource(R.drawable.icon_message_income);
                break;
            case "HOMEWORK":
                //作业
                im_type.setBackgroundResource(R.drawable.icon_message_homework);
                break;
            case "EVALUATE":
                //评价
                im_type.setBackgroundResource(R.drawable.icon_message_evaluate);
                break;
            case "GROUP_CHAT":
                //群聊
                im_type.setBackgroundResource(R.drawable.icon_message_group_chat);
                break;
            case "VIP":
                //会员
                im_type.setBackgroundResource(R.drawable.icon_message_vip);
                break;
            case "PIANO_ROOM":
                im_type.setBackgroundResource(R.drawable.icon_message_piano);
                break;
            case "STYLE":
                im_type.setBackgroundResource(R.drawable.icon_message_audit);
                break;
            default:
                //公告
                im_type.setBackgroundResource(R.drawable.icon_message_other);
                break;
        }
    }

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