package com.wisewoods.eduandroid.ui.adapter;

import android.graphics.Color;

import com.wisewoods.base.base.BaseVH;
import com.wisewoods.base.bean.ProjectList;
import com.wisewoods.base.page.BasePageAdapter;
import com.wisewoods.base.utils.$;
import com.wisewoods.eduandroid.R;
import com.wisewoods.eduandroid.app.ImgManager;
import com.wisewoods.eduandroid.view.LabelLinearLayout;

import org.jetbrains.annotations.NotNull;

public class ProjectAdapter extends BasePageAdapter<ProjectList.DataBean> {
    public ProjectAdapter() {
        super(R.layout.item_recycler_project);
        addChildClickViewIds(R.id.tv_show);
    }

    @Override
    protected void convert(@NotNull BaseVH baseVH, ProjectList.DataBean dataBean) {
        LabelLinearLayout llTag = baseVH.getView(R.id.ll_tag);
        String type = ImgManager.getTrainingType(dataBean.training_type);

        String start = $.timeFormat(dataBean.item_start);
        String end = $.timeFormat(dataBean.item_end);

        baseVH
                .setText(R.id.tv_project_name, dataBean.item_name)
                .setText(R.id.tv_project_time, start + "—" + end)
                .setText(R.id.tv_project_people, dataBean.people_num + "人参与培训")
                .setText(R.id.tv_project_type, type);

        if (dataBean.item_status == 1) {
            llTag.setLabelBackGroundGradienColor(Color.parseColor("#45FFF889"),
                    Color.parseColor("#45FF9600"));
            llTag.setTextContentColor(Color.parseColor("#F96210"));
            llTag.setTextContent("进行中");
        } else if (dataBean.item_status == 0) {
            llTag.setLabelBackGroundGradienColor(Color.parseColor("#45030000"),
                    Color.parseColor("#45FFFFFF"));
            llTag.setTextContentColor(Color.parseColor("#999999"));
            llTag.setTextContent("未开始");
        } else {
            llTag.setLabelBackGroundGradienColor(Color.parseColor("#45030000"),
                    Color.parseColor("#45FFFFFF"));
            llTag.setTextContentColor(Color.parseColor("#999999"));
            llTag.setTextContent("已结束");
        }
    }
}
