diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java index de902f0..438e5e8 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java @@ -150,16 +150,16 @@ public class MedicamentListActivity extends AppCompatActivity { private static DBMedoc dbMedoc; // private SimpleCursorAdapter drugAdapter; - private List medicaments; + private static List medicaments; private View mRecyclerView; private SimpleItemRecyclerViewAdapter mAdapter; - public int getCount() { + public static int getCount() { return medicaments.size(); } - public Medicament getItem(int position) { + public static Medicament getItem(int position) { return medicaments.get(position); } @@ -219,10 +219,10 @@ public class MedicamentListActivity extends AppCompatActivity { } } - if (this.medicaments == null) { - this.medicaments = dbHelper.getAllDrugs(); + if (medicaments == null) { + medicaments = dbHelper.getAllDrugs(); - Collections.sort(this.medicaments, new Comparator() { + Collections.sort(medicaments, new Comparator() { @Override public int compare(Medicament lhs, Medicament rhs) { return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()); @@ -298,14 +298,14 @@ public class MedicamentListActivity extends AppCompatActivity { startActivityForResult(intent, 0); } - public void newStockCalculation() { + public static void newStockCalculation(Context context) { Medicament currentMedicament; for (int position = 0 ; position < getCount() ; position++ ) { currentMedicament = getItem(position); currentMedicament.newStock(currentMedicament.getStock()); } - Toast.makeText( getApplicationContext(), "PillDroid - Calcul nouveau stocks", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, "PillDroid - Calcul nouveau stocks", Toast.LENGTH_SHORT).show(); // TODO: si un des médicaments est en rouge, on déclanche une notification visuelle pour dans 5 secondes } diff --git a/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java b/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java index f24c498..dd57fbe 100644 --- a/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java +++ b/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java @@ -18,7 +18,7 @@ public class PillDroidJobService extends JobService { @Override public boolean handleMessage(Message msg) { // Toast.makeText( getApplicationContext(), "PillDroid - Calcul nouveau stocks", Toast.LENGTH_SHORT).show(); -// MedicamentListActivity.newStockCalculation(); + MedicamentListActivity.newStockCalculation(getApplicationContext()); jobFinished( (JobParameters) msg.obj,false); return true;