From 017e28c016868182e07c4369093c9e466e7bb073 Mon Sep 17 00:00:00 2001 From: jacques Date: Wed, 30 Sep 2020 17:59:18 +0200 Subject: [PATCH] Fix the updateDrug bug (running since almost 6 months) --- .../pilldroid/MedicamentDetailActivity.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java index 3db75fe..a2b1794 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java @@ -112,6 +112,8 @@ public class MedicamentDetailActivity extends AppCompatActivity { DBHelper dbHelper = new DBHelper(this); + Medicament newMedicament = dbHelper.getDrugByCIP13(medicament.getCip13()); + View stockView; View priseView; View warningView; @@ -133,6 +135,7 @@ public class MedicamentDetailActivity extends AppCompatActivity { TextView warningTextView = warningView.findViewById(R.id.valeur); String warningValue = warningTextView.getText().toString(); + Log.d(TAG, "StockValue == "+ stockValue); Log.d(TAG, "PriseValue == "+ priseValue); Log.d(TAG, "AlertValue == "+ alertValue); @@ -140,13 +143,13 @@ public class MedicamentDetailActivity extends AppCompatActivity { Log.d(TAG, "medicamentID == "+ medicament.getId()); Log.d(TAG, "medicament == "+ medicament.toString()); - medicament.setStock(Double.parseDouble(stockValue)); - medicament.setPrise(Double.parseDouble(priseValue)); - medicament.setWarnThreshold(Integer.parseInt(warningValue)); - medicament.setAlertThreshold(Integer.parseInt(alertValue)); - medicament.setDateLastUpdate(); - medicament.setDateEndOfStock(); + newMedicament.setStock(Double.parseDouble(stockValue)); + newMedicament.setPrise(Double.parseDouble(priseValue)); + newMedicament.setWarnThreshold(Integer.parseInt(warningValue)); + newMedicament.setAlertThreshold(Integer.parseInt(alertValue)); + newMedicament.setDateLastUpdate(); + newMedicament.setDateEndOfStock(); - dbHelper.updateDrug(medicament); + dbHelper.updateDrug(newMedicament); } }