Bladeren bron

-fixing view binding in adapter

ilhamitubagoes 4 jaren geleden
bovenliggende
commit
78ba52af0a
1 gewijzigde bestanden met toevoegingen van 5 en 10 verwijderingen
  1. 5 10
      app/src/main/java/com/fusi24/rfid/adapter/ScanResultAdapter.java

+ 5 - 10
app/src/main/java/com/fusi24/rfid/adapter/ScanResultAdapter.java

@@ -3,7 +3,6 @@ package com.fusi24.rfid.adapter;
3 3
 import android.content.Context;
4 4
 import android.view.LayoutInflater;
5 5
 import android.view.ViewGroup;
6
-import android.widget.TextView;
7 6
 
8 7
 import androidx.annotation.NonNull;
9 8
 import androidx.recyclerview.widget.RecyclerView;
@@ -34,15 +33,11 @@ public class ScanResultAdapter extends RecyclerView.Adapter<ScanResultAdapter.Vi
34 33
     }
35 34
 
36 35
     static class ViewHolder extends RecyclerView.ViewHolder {
37
-        private TextView tvDocumentName;
38
-        private TextView tvDocumentStatus;
39
-        private TextView tvDocumentDate;
36
+        private RowDocumentBinding binding;
40 37
 
41 38
         ViewHolder(RowDocumentBinding itemBinding) {
42 39
             super(itemBinding.getRoot());
43
-            tvDocumentName = itemBinding.tvDocumentName;
44
-            tvDocumentStatus = itemBinding.tvDocumentStatus;
45
-            tvDocumentDate = itemBinding.tvDocumentStatus;
40
+            this.binding = itemBinding;
46 41
         }
47 42
     }
48 43
 
@@ -59,9 +54,9 @@ public class ScanResultAdapter extends RecyclerView.Adapter<ScanResultAdapter.Vi
59 54
 
60 55
         DataProblems problems = problemsList.get(position);
61 56
 
62
-        holder.tvDocumentName.setText(problems.getDataDocumentType().getName());
63
-        holder.tvDocumentStatus.setText(problems.getReason());
64
-        holder.tvDocumentDate.setText(DateHelper.convertDateToReadableDate(problems.getDataDocumentType().getUpdateDate()));
57
+        holder.binding.tvDocumentName.setText(problems.getDataDocumentType().getName());
58
+        holder.binding.tvDocumentStatus.setText(problems.getReason());
59
+        holder.binding.tvDocumentDate.setText(DateHelper.convertDateToReadableDate(problems.getDataDocumentType().getUpdateDate()));
65 60
 
66 61
     }
67 62