Call Utils.sortPrescriptionList

This commit is contained in:
jacques 2022-06-26 19:35:56 +02:00
parent 156ff07fc5
commit 589dc41709
2 changed files with 6 additions and 5 deletions

View file

@ -26,7 +26,6 @@ import java.util.List;
public class AlarmReceiver extends BroadcastReceiver {
private static final String TAG = AlarmManager.class.getName();
NotificationManager notificationManager;
@Override
@ -48,6 +47,8 @@ public class AlarmReceiver extends BroadcastReceiver {
PrescriptionDatabase prescriptions = PrescriptionDatabase.getInstanceDatabase(context.getApplicationContext());
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
List<Prescription> prescriptionList = prescriptionsDAO.getAllMedics();
prescriptionList = Utils.sortPrescriptionList(prescriptionList);
Prescription firstPrescription = null ;
try {
@ -88,7 +89,6 @@ public class AlarmReceiver extends BroadcastReceiver {
}
}
}
}
private void createNotificationChannel(Context context) {

View file

@ -286,7 +286,7 @@ public class DrugListActivity extends AppCompatActivity {
Prescription currentPrescription;
// Sorting list by dateEndOfStock
prescriptionList.sort(new Comparator<>() {
/*prescriptionList.sort(new Comparator<>() {
@Override
public int compare(Prescription lhs, Prescription rhs) {
if (lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()) != 0)
@ -294,11 +294,12 @@ public class DrugListActivity extends AppCompatActivity {
else
return (int) (lhs.getStock() - rhs.getStock());
}
});
});*/
prescriptionList = Utils.sortPrescriptionList(prescriptionList);
// Move Prescription with take==0 to the end of the list
for (int i=0 ; i < prescriptionList.size(); i++ ){
currentPrescription = prescriptionList.get(i);
currentPrescription = (Prescription) prescriptionList.get(i);
if (currentPrescription.getTake() == 0) {
prescriptionList.remove(currentPrescription);
prescriptionList.add(prescriptionList.size(), currentPrescription);