From b056c44661d7a422a106ea1535d10b7596053e52 Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Wed, 19 Oct 2016 17:41:51 +0200 Subject: [PATCH] =?UTF-8?q?correction=20appel=20=C3=A0=20newstockcalculati?= =?UTF-8?q?on=20depuis=20PillDroidJobService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foucry/pilldroid/MedicamentListActivity.java | 16 ++++++++-------- .../foucry/pilldroid/PillDroidJobService.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) 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;