refactoring and use Utils.sortPrescriptionList

This commit is contained in:
jacques 2022-06-29 04:57:26 +02:00
parent 5110e6b9b8
commit 8a218e7467

View file

@ -51,7 +51,6 @@ import net.foucry.pilldroid.models.Medicine;
import net.foucry.pilldroid.models.Prescription; import net.foucry.pilldroid.models.Prescription;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -286,15 +285,7 @@ public class DrugListActivity extends AppCompatActivity {
Prescription currentPrescription; Prescription currentPrescription;
// Sorting list by dateEndOfStock // Sorting list by dateEndOfStock
prescriptionList.sort(new Comparator<>() { Utils.sortPrescriptionList(prescriptionList);
@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());
}
});
// Move Prescription with take==0 to the end of the list // Move Prescription with take==0 to the end of the list
for (int i=0 ; i < prescriptionList.size(); i++ ){ for (int i=0 ; i < prescriptionList.size(); i++ ){