Blame view

footsafety/app/src/main/java/etelligens/com/foodsafety/adapter/UserBindPrinterModalAdopter.java 2.71 KB
f7a13682   “wangming”   项目初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  package etelligens.com.foodsafety.adapter;
  
  import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  import androidx.annotation.NonNull;
  import androidx.recyclerview.widget.RecyclerView;
  import etelligens.com.foodsafety.R;
  import etelligens.com.foodsafety.model.PrinterCustomerUseRecordsModal;
  import etelligens.com.foodsafety.model.UserBindPrinterModal;
  import org.jetbrains.annotations.NotNull;
  
  import java.util.ArrayList;
  
  /**
   * @author wj
   * @Description: 用户绑定打印机
   * @create 2024/2/26  11:12
   **/
  public class UserBindPrinterModalAdopter extends RecyclerView.Adapter<UserBindPrinterModalAdopter.UserBindPrinterViewHolder> {
      private Context context;
      private ArrayList<UserBindPrinterModal> userBindPrinterModals;
      OnItemClick onItemClick;
      public interface OnItemClick {
          void sendData(UserBindPrinterModal userBindPrinterModal);
      }
  
      public UserBindPrinterModalAdopter(Context context, ArrayList<UserBindPrinterModal> userBindPrinterModals, UserBindPrinterModalAdopter.OnItemClick onItemClick) {
          this.context = context;
          this.userBindPrinterModals = userBindPrinterModals;
          this.onItemClick = onItemClick;
      }
  
      View view;
  
      @NonNull
      @NotNull
      @Override
      public UserBindPrinterModalAdopter.UserBindPrinterViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
          view = LayoutInflater.from(context).inflate(R.layout.item_layout_user_bind_printer_item, parent, false);
          return new UserBindPrinterModalAdopter.UserBindPrinterViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(@NonNull @NotNull UserBindPrinterViewHolder holder, int position) {
          final UserBindPrinterModal userBindPrinterModal = userBindPrinterModals.get(position);
          holder.storeName.setText(userBindPrinterModal.getStoreID());
          holder.printerNameTxt.setText(userBindPrinterModal.getPrinterName());
          holder.llBindPrinterLayout.setOnClickListener(view -> onItemClick.sendData(userBindPrinterModal));
      }
  
  
      @Override
      public int getItemCount() {
          return userBindPrinterModals.size();
      }
      public class UserBindPrinterViewHolder extends RecyclerView.ViewHolder {
          LinearLayout llBindPrinterLayout;
          TextView storeName, printerNameTxt;
  
          public UserBindPrinterViewHolder(View itemview) {
              super(itemview);
              storeName = itemview.findViewById(R.id.store_name_txt);
              printerNameTxt = itemview.findViewById(R.id.printer_name_txt);
              llBindPrinterLayout = itemview.findViewById(R.id.ll_bind_printer_layout);
          }
      }
  }