package com.wisewoods.eduandroid.ui.adapter;

import android.graphics.Color;
import android.text.TextUtils;

import com.wisewoods.base.app.UserManager;
import com.wisewoods.base.base.BaseVH;
import com.wisewoods.base.bean.MettingInfo;
import com.wisewoods.base.page.BasePageAdapter;
import com.wisewoods.base.utils.$;
import com.wisewoods.eduandroid.R;

import org.jetbrains.annotations.NotNull;

public class MettingAdapter extends BasePageAdapter<MettingInfo.DataBean> {
    public MettingAdapter() {
        super(R.layout.item_recycler_room_live);
        addChildClickViewIds(R.id.tv_join, R.id.tv_cancel);
    }

    @Override
    protected void convert(@NotNull BaseVH baseVH, MettingInfo.DataBean dataBean) {
        String name = dataBean.subject;
        if (!TextUtils.isEmpty(dataBean.venue)) {
            name = name + "(" + dataBean.venue + ")";
        }
        baseVH
                .setText(R.id.tv_time, $.timeFormat4(dataBean.startTime) + "  " + $.weekFormat(dataBean.startTime))
                .setText(R.id.tv_year, $.timeFormat5(dataBean.startTime))
                .setText(R.id.tv_num, dataBean.meetingCode)
                .setText(R.id.tv_name, name)
                .setText(R.id.tv_metting_info, "会议时间：" + dataBean.startTime
                        + " — " + dataBean.endTime + "\n发起人：" + dataBean.createName)

        ;
        if (dataBean.status == 0) {
            baseVH.setText(R.id.tv_status, "未开始")
                    .setTextColor(R.id.tv_status, Color.parseColor("#FFFF543E"));
        } else if (dataBean.status == 1) {
            baseVH.setText(R.id.tv_status, "进行中")
                    .setTextColor(R.id.tv_status, Color.parseColor("#ff13d596"));
        }
        boolean isMe = UserManager.getUid().equals(dataBean.createId + "");
        baseVH.setGone(R.id.tv_cancel, !isMe && dataBean.status == 0);
        baseVH.setGone(R.id.tv_join, dataBean.status != 1);
    }
}
