mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-21 20:19:23 +01:00
change a method new;
use singleton for the database access.
This commit is contained in:
parent
dfaed88a56
commit
d6bd1590e8
2 changed files with 5 additions and 13 deletions
|
@ -55,7 +55,7 @@ public class DrugDetailActivity extends AppCompatActivity {
|
|||
public void onClick(View view) {
|
||||
Log.d(TAG, "Click on save icon");
|
||||
|
||||
getMDrugChanges();
|
||||
getDrugChanges();
|
||||
setResult(1);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right);
|
||||
|
@ -107,11 +107,10 @@ public class DrugDetailActivity extends AppCompatActivity {
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void getMDrugChanges() {
|
||||
private void getDrugChanges() {
|
||||
Log.d(TAG, "Time to save new values");
|
||||
|
||||
PrescriptionDatabase prescriptions = null;
|
||||
assert false;
|
||||
PrescriptionDatabase prescriptions = PrescriptionDatabase.getInstanceDatabase(this);
|
||||
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
|
||||
|
||||
Prescription newPrescription = prescriptionsDAO.getMedicByCIP13(aPrescription.getCip13());
|
||||
|
|
|
@ -93,17 +93,10 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
// Create medicines Room database from drugs.db files
|
||||
medicines = Room
|
||||
.databaseBuilder(getApplicationContext(), MedicineDatabase.class, "medicines")
|
||||
.createFromAsset("drugs.db")
|
||||
.allowMainThreadQueries()
|
||||
.build();
|
||||
medicines = MedicineDatabase.getInstanceDatabase(this);
|
||||
|
||||
// Create prescriptions Room database
|
||||
prescriptions = Room
|
||||
.databaseBuilder(getApplicationContext(), PrescriptionDatabase.class, "prescriptions")
|
||||
.allowMainThreadQueries()
|
||||
.build();
|
||||
prescriptions = PrescriptionDatabase.getInstanceDatabase(this);
|
||||
|
||||
// Manually migrate old database to room
|
||||
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
|
||||
|
|
Loading…
Reference in a new issue