From 24ec947239e7a207ddf6f7930371b04d248d29cd Mon Sep 17 00:00:00 2001 From: jacques Date: Sun, 13 Mar 2022 12:49:06 +0100 Subject: [PATCH] Change resource name --- .../pilldroid/CustomScannerActivity.java | 2 +- .../foucry/pilldroid/DrugDetailActivity.java | 2 +- .../foucry/pilldroid/DrugDetailContract.java | 1 - .../foucry/pilldroid/DrugListActivity.java | 29 ++----------------- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java b/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java index b3ff7c1..5a55f4e 100644 --- a/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java @@ -38,7 +38,7 @@ public class CustomScannerActivity extends Activity implements DecoratedBarcodeV public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_custom_scanner); + setContentView(R.layout.CustomScannerActivty); //barcodeScannerView.setTorchListener(this); diff --git a/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java index d1ed288..b205f36 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java @@ -41,7 +41,7 @@ public class DrugDetailActivity extends AppCompatActivity { aMedic = (Medic) bundle.get("medic"); Log.d(TAG, "aMedic == " + aMedic); - setContentView(R.layout.activity_drug_detail); + setContentView(R.layout.DrugDetailActivity); Toolbar toolbar = findViewById(detail_toolbar); if (toolbar != null) { diff --git a/app/src/main/java/net/foucry/pilldroid/DrugDetailContract.java b/app/src/main/java/net/foucry/pilldroid/DrugDetailContract.java index 7059816..1dcef08 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugDetailContract.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugDetailContract.java @@ -3,7 +3,6 @@ package net.foucry.pilldroid; import android.app.Activity; import android.content.Context; import android.content.Intent; -import android.os.Bundle; import androidx.activity.result.contract.ActivityResultContract; import androidx.annotation.NonNull; diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java index 75ec274..dad6084 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java @@ -55,7 +55,6 @@ import java.util.Locale; public class DrugListActivity extends AppCompatActivity { // Used for dev and debug final Boolean DEMO = true; - final Boolean DBDEMO = false; public final int CUSTOMIZED_REQUEST_CODE = 0x0000ffff; public final String BARCODE_FORMAT_NAME = "Barcode Format name"; @@ -64,7 +63,6 @@ public class DrugListActivity extends AppCompatActivity { private ActivityResultLauncher mBarcodeScannerLauncher; private static final String TAG = DrugListActivity.class.getName(); - private DBDrugs dbDrug; public PilldroidDatabase prescriptions; public PilldroidDatabase medications; @@ -110,10 +108,7 @@ public class DrugListActivity extends AppCompatActivity { .build(); // Set view content - setContentView(R.layout.activity_drug_list); - - DBHelper dbHelper = new DBHelper(this); - dbDrug = new DBDrugs(this); + setContentView(R.layout.DrugListActivity); Toolbar toolbar = findViewById(R.id.toolbar); @@ -122,11 +117,6 @@ public class DrugListActivity extends AppCompatActivity { toolbar.setTitle(getTitle()); } - // Added to drop database each the app is launch. - if (DBDEMO) { - dbHelper.dropDrug(); - } - if (DEMO) { MedicDAO medicDAO = prescriptions.getMedicDAO(); @@ -190,7 +180,6 @@ public class DrugListActivity extends AppCompatActivity { String cip13; // Handle successful scan - Log.d(TAG, "formatName = " + bundle.getString(BARCODE_FORMAT_NAME)); switch (bundle.getString(BARCODE_FORMAT_NAME)) { @@ -198,9 +187,6 @@ public class DrugListActivity extends AppCompatActivity { case "EAN_13": //CODE_128 || EAN 13 cip13 = bundle.getString(BARCODE_CONTENT); break; - case "CODE_39": - cip13 = dbDrug.getCIP13FromCIP7(bundle.getString(BARCODE_CONTENT)); - break; case "DATA_MATRIX": cip13 = bundle.getString(BARCODE_CONTENT).substring(4, 17); break; @@ -210,7 +196,6 @@ public class DrugListActivity extends AppCompatActivity { } // Get Drug from database - //final Drug scannedDrug = dbDrug.getDrugByCIP13(cip13); MedicDAO medicationDAO = medications.getMedicDAO(); final Medic scannedMedication = medicationDAO.getMedicByCIP13(cip13); @@ -258,14 +243,7 @@ public class DrugListActivity extends AppCompatActivity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - if (requestCode == CUSTOMIZED_REQUEST_CODE) { - if (BuildConfig.DEBUG) { - Toast.makeText(this, "REQUEST_CODE = " + requestCode + - "RESULT_CODE = " + resultCode, Toast.LENGTH_LONG).show(); - } - Log.d(TAG, "REQUEST_CODE = " + requestCode + " RESULT_CODE = " + resultCode); - constructDrugsList(); - } + constructDrugsList(); } public void onPause() { @@ -283,8 +261,7 @@ public class DrugListActivity extends AppCompatActivity { public void onButtonClick() { Log.d(TAG, "add medication"); ScanOptions options = new ScanOptions(); - options.setDesiredBarcodeFormats(ScanOptions.DATA_MATRIX, ScanOptions.CODE_39, - ScanOptions.CODE_128); + options.setDesiredBarcodeFormats(ScanOptions.DATA_MATRIX, ScanOptions.CODE_128); options.setCameraId(0); // Use a specific camera of the device options.setBeepEnabled(true); options.setBarcodeImageEnabled(true);