Procházet zdrojové kódy

-Prevent for multiple scan (added stop in method onPause)
-prevent for adding group when nothing problem list from service

ilhamitubagoes před 4 roky
rodič
revize
bc27feaf8b

+ 3 - 0
app/src/main/java/com/fusi24/entryPermitScanner/ui/ScanActivity.java

@@ -115,6 +115,7 @@ public class ScanActivity extends LFScanProcessing implements GoogleApiClient.Co
115 115
     @Override
116 116
     protected void onResume() {
117 117
         super.onResume();
118
+        statusScanner();
118 119
         //Now lets connect to the API
119 120
         mGoogleApiClient.connect();
120 121
 
@@ -125,6 +126,8 @@ public class ScanActivity extends LFScanProcessing implements GoogleApiClient.Co
125 126
     @Override
126 127
     protected void onPause() {
127 128
         super.onPause();
129
+        // Stop scanner when scan activity pause
130
+        onStop();
128 131
         //Disconnect from API onPause()
129 132
         if (mGoogleApiClient.isConnected()) {
130 133
             LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);

+ 9 - 7
app/src/main/java/com/fusi24/entryPermitScanner/ui/scanresult/ScanResultActivity.java

@@ -204,13 +204,15 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
204 204
 
205 205
         // Search if all data problem document not have any group
206 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());
207
+            if (problemsList.size() != 0){
208
+                if (Stream.of(problemsList).allMatch(v -> v.getDataDocumentType().getGroup() == null)) {
209
+                    groupList.add(new DataGroup(1, "No Group", "No Group Document", true));
210
+                } else {
211
+                    groupList = Stream.of(problemsList)
212
+                            .map(v -> v.getDataDocumentType().getGroup())
213
+                            .distinctBy(DataGroup::getId)
214
+                            .collect(Collectors.toList());
215
+                }
214 216
             }
215 217
         }
216 218