Add drug comparaison between the original drug and the saved one.

This commit is contained in:
jacques 2021-12-28 15:09:52 +01:00
parent 592079bd01
commit b6d0322acd

View file

@ -28,6 +28,8 @@ public class DrugDetailActivity extends AppCompatActivity {
private static final String TAG = DrugDetailActivity.class.getName();
Drug drug;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -109,8 +111,7 @@ public class DrugDetailActivity extends AppCompatActivity {
return super.onOptionsItemSelected(item);
}
private void getMDrugChanges()
{
private void getMDrugChanges() {
Log.d(TAG, "Time to save new values");
DBHelper dbHelper = new DBHelper(this);
@ -142,9 +143,14 @@ public class DrugDetailActivity extends AppCompatActivity {
newDrug.setTake(Double.parseDouble(takeValue));
newDrug.setWarnThreshold(Integer.parseInt(warningValue));
newDrug.setAlertThreshold(Integer.parseInt(alertValue));
newDrug.setDateLastUpdate(new Date().getTime());
newDrug.setDateEndOfStock();
dbHelper.updateDrug(newDrug);
if (drug.equals(newDrug)) {
Log.d(TAG, "drug and newDrug are Equals");
} else {
Log.d(TAG, "drug and newDrug are NOT Equals");
newDrug.setDateLastUpdate(new Date().getTime());
dbHelper.updateDrug(newDrug);
}
}
}