mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Add more cancel case in scan return
This commit is contained in:
parent
273ae8bdfe
commit
15b7c52b66
1 changed files with 25 additions and 1 deletions
|
@ -296,6 +296,30 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
super.onResume();
|
||||
}
|
||||
|
||||
/** Register the launcher and result handler
|
||||
* ActivityResultLauncher
|
||||
*/
|
||||
private final ActivityResultLauncher<ScanOptions> barcodeLauncher = registerForActivityResult(new ScanContract(),
|
||||
result -> {
|
||||
if(result.getContents() == null) {
|
||||
Intent originalIntent = result.getOriginalIntent();
|
||||
if (originalIntent == null {
|
||||
Log.d(TAG, "Cancelled Scan");
|
||||
Toast.makeText(DrugListActivity.this, "Cancelled", Toast.LENGTH_LONG).show();
|
||||
} else if (originalIntent.hasExtra(Intents.Scan.MISSING_CAMERA_PERMISSION)) {
|
||||
Log.d(TAG, "Cancelled scan due missing camera permission");
|
||||
Toast.makeText(DrugListaActivity.this, "Cancelled due missing camera persmission",
|
||||
Toast.LENGTH_LONG.show());
|
||||
} else if (originalIntent.hasExtra(Intents.Scan.TIMEOUT)) {
|
||||
Log.d(TAG, "Cancelled due timeout");
|
||||
Toast,makeText(DrugListActivity.this, "Cancelled due timeout", Toast.LENGTH_LONG.show());
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "Scanned");
|
||||
Toast.makeText(DrugListActivity.this, "Scanned: " + result.getContents(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Launch scan
|
||||
public void onButtonClick() {
|
||||
|
@ -306,7 +330,7 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
options.setCameraId(0); // Use a specific camera of the device
|
||||
options.setBeepEnabled(true);
|
||||
options.setBarcodeImageEnabled(true);
|
||||
//options.setTimeout(3600);
|
||||
options.setTimeout(60);
|
||||
options.setCaptureActivity(CustomScannerActivity.class);
|
||||
options.setBeepEnabled(true);
|
||||
options.addExtra(Intents.Scan.SCAN_TYPE, Intents.Scan.MIXED_SCAN);
|
||||
|
|
Loading…
Reference in a new issue