package com.wisewoods.eduandroid.ui.adapter;

import com.wisewoods.base.base.BaseVH;
import com.wisewoods.base.bean.TaskList;
import com.wisewoods.base.page.BasePageAdapter;
import com.wisewoods.eduandroid.R;

import org.jetbrains.annotations.NotNull;

public class TaskAdapter extends BasePageAdapter<TaskList.TaskBean> {
    private int state;

    public TaskAdapter(int state) {
        super(R.layout.item_recycler_task);
        addChildClickViewIds(R.id.tv_car_put, R.id.tv_complete, R.id.tv_plan);
        this.state = state;
    }

    @Override
    protected void convert(@NotNull BaseVH baseVH, TaskList.TaskBean taskBean) {
        baseVH.setText(R.id.tv_time, taskBean.prepTime)
                .setText(R.id.tv_tag, taskBean.prepName)
                .setText(R.id.tv_content, taskBean.taskContent)
                .setGone(R.id.tv_time, state != 0)
                .setGone(R.id.tv_state, state == 0);

        switch (taskBean.prepName) {
            case "餐饮需求":
                baseVH.setImageResource(R.id.iv_tag, R.drawable.ic_task_blue)
                        .setGone(R.id.tv_car_put, true)
                        .setGone(R.id.tv_complete, state == 1)
                        .setGone(R.id.tv_plan, true)
                        .setGone(R.id.v_line, state == 1);
                break;
            case "乘车需求":
                baseVH.setImageResource(R.id.iv_tag, R.drawable.ic_task_green)
                        .setGone(R.id.tv_car_put, state == 1)
                        .setGone(R.id.tv_complete, true)
                        .setGone(R.id.tv_plan, state == 0)
                        .setGone(R.id.v_line, false);
                break;
            case "住宿需求":
                baseVH.setImageResource(R.id.iv_tag, R.drawable.ic_task_yellow)
                        .setGone(R.id.tv_car_put, true)
                        .setGone(R.id.tv_complete, state == 1)
                        .setGone(R.id.tv_plan, true)
                        .setGone(R.id.v_line, state == 1);
                break;
            case "训前准备":
                baseVH.setImageResource(R.id.iv_tag, R.drawable.ic_task_red)
                        .setGone(R.id.tv_car_put, true)
                        .setGone(R.id.tv_complete, state == 1)
                        .setGone(R.id.tv_plan, true)
                        .setGone(R.id.v_line, state == 1);
                break;
            default:
                baseVH.setImageResource(R.id.iv_tag, R.drawable.ic_task_red)
                        .setGone(R.id.tv_car_put, true)
                        .setGone(R.id.tv_complete, state == 1)
                        .setGone(R.id.tv_plan, true)
                        .setGone(R.id.v_line, state == 1);
                break;
        }
    }
}
