package com.naz.sdkdemo.adaapter;

import android.annotation.SuppressLint;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.naz.sdkdemo.R;
import com.naz.sdkdemo.bean.ScanInfo;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class ScanMarkAdapter extends BaseQuickAdapter<ScanInfo, BaseViewHolder> {
   private List<ScanInfo> mList;
   public ScanMarkAdapter(@Nullable List<ScanInfo> data) {
      super(R.layout.item_scan_code, data);
      mList = data;
   }

   @Override
   protected void convert(@NonNull BaseViewHolder holder, ScanInfo info) {
      holder.setText(R.id.tv_name, info.material_code_show);
      holder.setText(R.id.tv_count, "数量："+info.qty);
      holder.getView(R.id.delete).setOnClickListener(new View.OnClickListener() {
         @SuppressLint("NotifyDataSetChanged")
         @Override
         public void onClick(View v) {
            mList.remove(info);
            notifyDataSetChanged();
         }
      });
   }
}
