From 410ef5eb45412b3c042c6348350ed2babad63e66 Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 31 May 2020 07:32:42 +0200 Subject: [PATCH] Add start logical for onActivity result --- .../pilldroid/MedicamentListActivity.java | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java index 853f13b..9eb364c 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java @@ -66,6 +66,7 @@ public class MedicamentListActivity extends AppCompatActivity { final Boolean DBDEMO = true; final static Random random = new Random(); public final int CUSTOMIZED_REQUEST_CODE = 0x0000ffff; + public final int SAVE_RQUEST_CODE = 0x000000ff; @Override public void onStart() { @@ -286,27 +287,37 @@ public class MedicamentListActivity extends AppCompatActivity { } switch (requestCode) { case CUSTOMIZED_REQUEST_CODE: { - Toast.makeText(this, "REQUEST_CODE = " + requestCode, Toast.LENGTH_LONG).show(); + Toast.makeText(this, "REQUEST_CODE = " + requestCode + "RESULT_CODE == " + resultCode, Toast.LENGTH_LONG).show(); + Log.d(TAG, "requestCode == "+ requestCode); + Log.d(TAG, "resultCode == " + resultCode); break; } - default: + case SAVE_RQUEST_CODE: { + Toast.makeText(this, "REQUEST_CODE = " + requestCode + "RESULT_CODE == " + resultCode, Toast.LENGTH_LONG).show(); + Log.d(TAG, "requestCode == "+ requestCode); + Log.d(TAG, "resultCode == " + resultCode); break; - } - - IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data); - - if(result.getContents() == null) { - Intent originalIntent = result.getOriginalIntent(); - if (originalIntent == null) { - Log.d(TAG, "Cancelled scan"); - Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show(); - } else if(originalIntent.hasExtra(Intents.Scan.MISSING_CAMERA_PERMISSION)) { - Log.d(TAG,"Cancelled scan due to missing camera permission"); - Toast.makeText(this, "Cancelled due to missing camera permission", Toast.LENGTH_LONG).show(); } - } else { - Log.d(TAG, "Scanned"); - Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show(); + default { + Toast.makeText(this, "REQUEST_CODE = " + requestCode + "RESULT_CODE == " + resultCode, Toast.LENGTH_LONG).show(); + Log.d(TAG, "requestCode == "+ requestCode); + Log.d(TAG, "resultCode == " + resultCode); + IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data); + + if(result.getContents() == null) { + Intent originalIntent = result.getOriginalIntent(); + if (originalIntent == null) { + Log.d(TAG, "Cancelled scan"); + Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show(); + } else if(originalIntent.hasExtra(Intents.Scan.MISSING_CAMERA_PERMISSION)) { + Log.d(TAG,"Cancelled scan due to missing camera permission"); + Toast.makeText(this, "Cancelled due to missing camera permission", Toast.LENGTH_LONG).show(); + } + } else { + Log.d(TAG, "Scanned"); + Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show(); + } + } } } @@ -533,4 +544,4 @@ public class MedicamentListActivity extends AppCompatActivity { constructMedsList(); } } - */ \ No newline at end of file + */