package com.tenlionsoft.oamodule.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tenlionsoft.baselib.core.widget.base.BaseRecyclerAdapter;
import com.tenlionsoft.oamodule.R;
import com.tenlionsoft.oamodule.beans.BySuperviseListBean;
import com.tenlionsoft.oamodule.beans.SuperviseBean;
import com.tenlionsoft.oamodule.holder.SuperviseHolder;

import java.util.List;

/**
 * 作者: adam
 * 日期: 2022/4/18 - 17:43
 * 邮箱: itgaojian@163.com
 * 描述:
 */
public class SuperviseAdapter extends BaseRecyclerAdapter<Object, SuperviseHolder> {

    public SuperviseAdapter(Context ctx, List<Object> list) {
        super(ctx, list);
    }

    @Override
    public SuperviseHolder createHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(mContext).inflate(R.layout.item_supervice, parent, false);
        return new SuperviseHolder(itemView);
    }

    @Override
    public void bindHolder(SuperviseHolder h, int i) {
        Object o = mData.get(i);
        if (o instanceof SuperviseBean) {
            SuperviseBean bean = (SuperviseBean) o;
            h.mTvName.setText("督办名称:" + bean.getOverseeTitle());
            h.mTvContent.setText("督办内容:" + bean.getOverseeContent());
            h.mTvTime.setText("完成时限:" + bean.getOverseeCompleteTime());
            h.mTvType.setText(bean.getOverseeTypeName());
            h.mTvState.setVisibility(View.GONE);
        } else if (o instanceof BySuperviseListBean.RowsBean) {
            BySuperviseListBean.RowsBean bean = (BySuperviseListBean.RowsBean) o;
            h.mTvName.setText("督办名称:" + bean.getOverseeDTO().getOverseeTitle());
            h.mTvContent.setText("督办内容:" + bean.getOverseeDTO().getOverseeContent());
            h.mTvTime.setText("完成时限:" + bean.getOverseeDTO().getOverseeCompleteTime());
            h.mTvType.setText(bean.getOverseeDTO().getOverseeTypeName());
            h.mTvState.setVisibility(View.VISIBLE);
            h.mTvState.setText("nto".equals(bean.getStatus()) ? "未办结" : "已办结");
        }
    }
}
