From 6e6838d2d2893db56430f2a922b1cebb6cb3bbdd Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sat, 25 Apr 2020 12:05:00 +0200 Subject: [PATCH 1/3] Cosmetic change --- app/src/main/java/net/foucry/pilldroid/DBHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/net/foucry/pilldroid/DBHelper.java b/app/src/main/java/net/foucry/pilldroid/DBHelper.java index a8a93fc..0081a37 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBHelper.java +++ b/app/src/main/java/net/foucry/pilldroid/DBHelper.java @@ -277,7 +277,7 @@ class DBHelper extends SQLiteOpenHelper { // Update row int i = db.update(TABLE_DRUG, // table values, // column/value - KEY_ID+" = ?", // selections + KEY_ID+" = ?", // selections new String[] {String.valueOf(medicament.getId()) } ); // selections args // Close DB From 58d709152e37dfb74680f0cc8f35f2b0c5869be0 Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sat, 25 Apr 2020 12:06:05 +0200 Subject: [PATCH 2/3] Use DBHelper to update medicament. Change log. --- .../java/net/foucry/pilldroid/MedicamentDetailFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java index 2d2f8e4..e9af23a 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java @@ -32,6 +32,7 @@ public class MedicamentDetailFragment extends Fragment { * The dummy content this fragment is presenting. */ private Medicament medicament; + private DBHelper dbHelper = new DBHelper(); /** * Mandatory empty constructor for the fragment manager to instantiate the @@ -123,6 +124,7 @@ public class MedicamentDetailFragment extends Fragment { { Context context = getContext(); View currentView = getView(); + // View nameView; // View adminModeView; // View presentationView; @@ -153,8 +155,9 @@ public class MedicamentDetailFragment extends Fragment { Log.d(TAG, "AlertValue == "+ alertValue); Log.d(TAG, "WarningValue == "+ warningValue); Log.d(TAG, "medicamentID == "+ medicament.getId()); - Log.d(TAG, "medicament == "+ medicament); + Log.d(TAG, "medicament == "+ medicament.toString()); + dbHelper.updateDrug(medicament); super.onStop(); } } From f90c0df17b2e98c5f0674b58c0db7fa8181f4918 Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sat, 25 Apr 2020 12:07:29 +0200 Subject: [PATCH 3/3] disabled demo mode; Use DBHelper to updateDrug after currentStock updateed --- .../java/net/foucry/pilldroid/MedicamentListActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java index e896b01..09ae7af 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java @@ -62,8 +62,8 @@ public class MedicamentListActivity extends AppCompatActivity { // TODO: Change DEMO/DBDEMO form statci to non-static. In order to create fake data at only at launchtime private boolean mTwoPane; - final static Boolean DEMO = true; - final static Boolean DBDEMO = true; + final Boolean DEMO = false; + final Boolean DBDEMO = false; final static Random random = new Random(); @Override @@ -232,12 +232,14 @@ public class MedicamentListActivity extends AppCompatActivity { public void newStockCalculation() { Medicament currentMedicament; + DBHelper dbHelper = new DBHelper(); + for (int position = 0 ; position < this. getCount() ; position++ ) { currentMedicament = this.getItem(position); currentMedicament.newStock(currentMedicament.getStock()); + dbHelper.updateDrug(currentMedicament); } -// TODO: Must record new stock in DB // TODO: si un des médicaments est en rouge, on déclanche une notification visuelle pour dans 5 secondes Calendar calendar = Calendar.getInstance();