mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Move sorting list from DrugListActivity to Utils.
This commit is contained in:
parent
253e2ea18d
commit
156ff07fc5
1 changed files with 15 additions and 0 deletions
|
@ -3,7 +3,9 @@ package net.foucry.pilldroid;
|
|||
import net.foucry.pilldroid.models.Medicine;
|
||||
import net.foucry.pilldroid.models.Prescription;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -45,4 +47,17 @@ public class Utils {
|
|||
|
||||
return aPrescription;
|
||||
}
|
||||
|
||||
public static List<Prescription> sortPrescriptionList(List<Prescription> prescriptionList) {
|
||||
prescriptionList.sort(new Comparator<Prescription>() {
|
||||
@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());
|
||||
}
|
||||
});
|
||||
return prescriptionList;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue