From 80daeb0923a3a99de32cd3397eb79efb2285d17b Mon Sep 17 00:00:00 2001 From: jacques Date: Thu, 23 Jun 2022 11:03:42 +0200 Subject: [PATCH] Add iterator in contructList to change list order (not yet tested) --- .../java/net/foucry/pilldroid/DrugListActivity.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java index a6cd73c..159ae73 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java @@ -53,6 +53,7 @@ import net.foucry.pilldroid.models.Prescription; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; +import java.util.ListIterator; import java.util.Locale; /** @@ -283,6 +284,18 @@ public class DrugListActivity extends AppCompatActivity { PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO(); prescriptionList = prescriptionsDAO.getAllMedics(); + ListIterator listIterator = prescriptionList.listIterator(); + Prescription currentPrescription; + + while (listIterator.hasNext()) { + currentPrescription = listIterator.next(); + + if (currentPrescription.getTake() == 0) { + prescriptionList.remove(currentPrescription); + prescriptionList.add(prescriptionList.size(), currentPrescription); + } + } + View mRecyclerView = findViewById(R.id.drug_list); assert mRecyclerView != null; setupRecyclerView((RecyclerView) mRecyclerView);