Przeglądaj źródła

-Add case when data group from document ALL NULL

ilhamitubagoes 4 lat temu
rodzic
commit
170bbe03b4

+ 4 - 1
app/src/main/java/com/fusi24/entryPermitScanner/adapter/ProblemDocumentAdapter.java

@@ -10,6 +10,7 @@ import android.widget.Filterable;
10 10
 import androidx.annotation.NonNull;
11 11
 import androidx.recyclerview.widget.RecyclerView;
12 12
 
13
+import com.annimon.stream.Stream;
13 14
 import com.fusi24.entryPermitScanner.data.entity.DataProblems;
14 15
 import com.fusi24.entryPermitScanner.databinding.RowDocumentBinding;
15 16
 import com.fusi24.entryPermitScanner.util.DateHelper;
@@ -78,7 +79,9 @@ public class ProblemDocumentAdapter extends RecyclerView.Adapter<ProblemDocument
78 79
                     List<DataProblems> filterList = new ArrayList<>();
79 80
 
80 81
                     for (DataProblems problems : problemsList){
81
-                        if (problems.getDataDocumentType().getGroup().getId().equals(idGroup)){
82
+                        if (Stream.of(problemsList).allMatch(v -> v.getDataDocumentType().getGroup() == null)){
83
+                            filterList.add(problems);
84
+                        } else if (problems.getDataDocumentType().getGroup().getId().equals(idGroup)){
82 85
                             filterList.add(problems);
83 86
                         }
84 87
                     }

+ 7 - 0
app/src/main/java/com/fusi24/entryPermitScanner/data/entity/DataGroup.java

@@ -7,6 +7,13 @@ public class DataGroup {
7 7
     private String description;
8 8
     private boolean isActive;
9 9
 
10
+    public DataGroup(Integer id, String name, String description, boolean isActive) {
11
+        this.id = id;
12
+        this.name = name;
13
+        this.description = description;
14
+        this.isActive = isActive;
15
+    }
16
+
10 17
     public Integer getId() {
11 18
         return id;
12 19
     }

+ 14 - 4
app/src/main/java/com/fusi24/entryPermitScanner/ui/scanresult/ScanResultActivity.java

@@ -199,10 +199,20 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
199 199
         problemsList = dataResultRfid.getProblems();
200 200
 
201 201
         // Function mapping data problem by Group
202
-        List<DataGroup> groupList = Stream.of(problemsList)
203
-                .map(v -> v.getDataDocumentType().getGroup())
204
-                .distinctBy(DataGroup::getId)
205
-                .collect(Collectors.toList());
202
+        List<DataGroup> groupList = new ArrayList<>();
203
+        groupList.clear();
204
+
205
+        // Search if all data problem document not have any group
206
+        if (!dataResultRfid.getPassed()) {
207
+            if (Stream.of(problemsList).allMatch(v -> v.getDataDocumentType().getGroup() == null)) {
208
+                groupList.add(new DataGroup(1, "No Group", "No Group Document", true));
209
+            } else {
210
+                groupList = Stream.of(problemsList)
211
+                        .map(v -> v.getDataDocumentType().getGroup())
212
+                        .distinctBy(DataGroup::getId)
213
+                        .collect(Collectors.toList());
214
+            }
215
+        }
206 216
 
207 217
         adapter.updateGroupList(groupList);
208 218
         adapter.updateProblemList(problemsList);