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.RoutineAcceptListBean;
import com.tenlionsoft.oamodule.beans.RoutineBean;
import com.tenlionsoft.oamodule.holder.RoutineHolder;

import java.util.List;

/**
 * 作者: adam
 * 日期: 2022/4/15 - 17:50
 * 邮箱: itgaojian@163.com
 * 描述:
 */
public class RoutineAdapter extends BaseRecyclerAdapter<Object, RoutineHolder> {

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

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

    @Override
    public void bindHolder(RoutineHolder h, int i) {
        Object o = mData.get(i);
        if (o instanceof RoutineBean) {
            //我发起的
            RoutineBean bean = (RoutineBean) o;
            h.mTvTitle.setText(bean.getWorkName());
            h.mTvTime.setText(bean.getWorkCompleteStartTime()+"-"+bean.getWorkCompleteEndTime());
            h.mTvTl.setText(bean.getWorkCompleteDay()+"个工作日");
            h.mTvUser.setText(bean.getWorkUndertakerUserName());
        } else if (o instanceof RoutineAcceptListBean.RowsBean) {
            RoutineAcceptListBean.RowsBean bean = (RoutineAcceptListBean.RowsBean) o;
            h.mTvTitle.setText(bean.getRoutineWorkDTO().getWorkName());
            h.mTvTime.setText(bean.getRoutineWorkDTO().getWorkCompleteStartTime()+"-"+bean.getRoutineWorkDTO().getWorkCompleteEndTime());
            h.mTvTl.setText(bean.getRoutineWorkDTO().getWorkCompleteDay()+"个工作日");
            h.mTvUser.setText(bean.getRoutineWorkDTO().getWorkUndertakerUserName());
        }
    }
}
