package com.casic.dcms.adapter;

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

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.casic.dcms.R;
import com.casic.dcms.bean.CaseProcessBean;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class ProcessLineAdapter extends RecyclerView.Adapter<ProcessLineAdapter.ViewHolder> {
    private Context mContext;
    private List<CaseProcessBean.DataBean> mProcessList;

    public ProcessLineAdapter(Context context, List<CaseProcessBean.DataBean> list) {
        mContext = context;
        this.mProcessList = list;
    }

    @NotNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_case_process, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        CaseProcessBean.DataBean dataBean = mProcessList.get(position);
        String typeName = dataBean.getOperationTypeName();
        holder.operationTypeName.setText(typeName);
        holder.handlePersonView.setText(dataBean.getUserName());
        holder.handleTimeView.setText(dataBean.getTime());
        holder.handleResultView.setText(dataBean.getRemarks());
    }

    @Override
    public int getItemViewType(int position) {
        return super.getItemViewType(position);
    }

    @Override
    public int getItemCount() {
        return mProcessList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        private TextView operationTypeName;
        private TextView handlePersonView;
        private TextView handleTimeView;
        private TextView handleResultView;
        private RecyclerView handlePicView;

        public ViewHolder(View view) {
            super(view);
            operationTypeName = view.findViewById(R.id.operationTypeName);
            handlePersonView = view.findViewById(R.id.handlePersonView);
            handleTimeView = view.findViewById(R.id.handleTimeView);
            handleResultView = view.findViewById(R.id.handleResultView);
            handlePicView = view.findViewById(R.id.handlePicView);
        }
    }
}