From 8a218e746768df0a6c4971a9b19c058fec180496 Mon Sep 17 00:00:00 2001 From: jacques Date: Wed, 29 Jun 2022 04:57:26 +0200 Subject: [PATCH] refactoring and use Utils.sortPrescriptionList --- .../java/net/foucry/pilldroid/DrugListActivity.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java index b0846da..bb1f02a 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java @@ -51,7 +51,6 @@ import net.foucry.pilldroid.models.Medicine; import net.foucry.pilldroid.models.Prescription; import java.text.SimpleDateFormat; -import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.Locale; @@ -286,15 +285,7 @@ public class DrugListActivity extends AppCompatActivity { Prescription currentPrescription; // Sorting list by dateEndOfStock - prescriptionList.sort(new Comparator<>() { - @Override - public int compare(Prescription lhs, Prescription rhs) { - if (lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()) != 0) - return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()); - else - return (int) (lhs.getStock() - rhs.getStock()); - } - }); + Utils.sortPrescriptionList(prescriptionList); // Move Prescription with take==0 to the end of the list for (int i=0 ; i < prescriptionList.size(); i++ ){