Browse Source

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

ilhamitubagoes 4 years ago
parent
commit
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
     @Override
115
     @Override
116
     protected void onResume() {
116
     protected void onResume() {
117
         super.onResume();
117
         super.onResume();
118
+        statusScanner();
118
         //Now lets connect to the API
119
         //Now lets connect to the API
119
         mGoogleApiClient.connect();
120
         mGoogleApiClient.connect();
120
 
121
 
@@ -125,6 +126,8 @@ public class ScanActivity extends LFScanProcessing implements GoogleApiClient.Co
125
     @Override
126
     @Override
126
     protected void onPause() {
127
     protected void onPause() {
127
         super.onPause();
128
         super.onPause();
129
+        // Stop scanner when scan activity pause
130
+        onStop();
128
         //Disconnect from API onPause()
131
         //Disconnect from API onPause()
129
         if (mGoogleApiClient.isConnected()) {
132
         if (mGoogleApiClient.isConnected()) {
130
             LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
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
         // Search if all data problem document not have any group
205
         // Search if all data problem document not have any group
206
         if (!dataResultRfid.getPassed()) {
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