package com.example.beijing_daxing.adapter;

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

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.example.beijing_daxing.BR;
import com.example.beijing_daxing.R;
import com.example.beijing_daxing.base.AdapterClickCall;
import com.example.beijing_daxing.been.PmRecordPenalty;
import com.example.beijing_daxing.been.Stock;
import com.example.beijing_daxing.databinding.ItemCheckBinding;
import com.example.beijing_daxing.databinding.ItemPPBinding;

import java.util.List;

/**
 * @author wanghao
 * @date 2024/1/19  14:32
 */
public class PersonPenaltyAdapter extends RecyclerView.Adapter<PersonPenaltyAdapter.MyViewHoder> {
    private Context context;
    private List<PmRecordPenalty> list;
    private LayoutInflater inflater;

    public PersonPenaltyAdapter(Context context, AdapterClickCall call) {
        this.context = context;
        inflater = LayoutInflater.from(context);

    }

    public void setList(List<PmRecordPenalty> list) {
        this.list = list;
    }

    @Override
    public MyViewHoder onCreateViewHolder(ViewGroup parent, int viewType) {
        ItemPPBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_p_p, parent, false);
        return new MyViewHoder(binding);
    }

    @Override
    public void onBindViewHolder(MyViewHoder holder, int position) {
        var binding = holder.getBinding();
        binding.setVariable(BR.item,list.get(position));

    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    public class MyViewHoder extends RecyclerView.ViewHolder {
        private ItemPPBinding binding;

        public MyViewHoder( ItemPPBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }

        public ItemPPBinding getBinding() {
            return binding;
        }
    }
}
