mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-17 18:41:37 +01:00
change create List behavior
This commit is contained in:
parent
7bf9acaaf1
commit
cdbaf79823
1 changed files with 29 additions and 10 deletions
|
@ -160,7 +160,7 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
if (medicaments == null) {
|
||||
/* if (medicaments == null) {
|
||||
medicaments = dbHelper.getAllDrugs();
|
||||
|
||||
Collections.sort(medicaments, new Comparator<Medicament>() {
|
||||
|
@ -170,6 +170,8 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
constructMedsList();
|
||||
|
||||
mRecyclerView = findViewById(R.id.medicament_list);
|
||||
assert mRecyclerView != null;
|
||||
|
@ -227,15 +229,6 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
*/
|
||||
public void newStockCalculation() {
|
||||
|
||||
Medicament currentMedicament;
|
||||
dbHelper = new DBHelper(this);
|
||||
|
||||
for (int position = 0 ; position < this. getCount() ; position++ ) {
|
||||
currentMedicament = this.getItem(position);
|
||||
currentMedicament.newStock(currentMedicament.getStock());
|
||||
dbHelper.updateDrug(currentMedicament);
|
||||
}
|
||||
|
||||
// TODO: si un des médicaments est en rouge, on déclanche une notification visuelle pour dans 5 secondes
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
@ -451,6 +444,32 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
});
|
||||
}
|
||||
|
||||
protected void constructMedsList()
|
||||
{
|
||||
Medicament currentMedicament;
|
||||
dbHelper = new DBHelper(this);
|
||||
|
||||
if (!medicaments.isEmpty()) {
|
||||
medicaments.clear();
|
||||
}
|
||||
|
||||
medicaments = dbHelper.getAllDrugs();
|
||||
|
||||
Collections.sort(medicaments, new Comparator<Medicament>() {
|
||||
@Override
|
||||
public int compare(Medicament lhs, Medicament rhs) {
|
||||
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
|
||||
}
|
||||
});
|
||||
|
||||
for (int position = 0 ; position < this. getCount() ; position++ ) {
|
||||
currentMedicament = this.getItem(position);
|
||||
currentMedicament.newStock(currentMedicament.getStock());
|
||||
dbHelper.updateDrug(currentMedicament);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mValues.size();
|
||||
|
|
Loading…
Reference in a new issue