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 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(); } } 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();