Replace mindSdk-24 comparator.reversed() call with explicit reverse comparator

pull/556/head
Scrimbly 6 years ago
parent 2140f0241e
commit cc4ad53541

@ -139,6 +139,14 @@ public class MemoryHabitList extends HabitList
else return s2.compareTo(s1); else return s2.compareTo(s1);
}; };
Comparator<Habit> ascendingScoreComparator = (h2, h1) ->
{
Double s1 = h1.getScores().getTodayValue();
Double s2 = h2.getScores().getTodayValue();
if (s1.equals(s2)) return nameComparator.compare(h1, h2);
else return s2.compareTo(s1);
};
Comparator<Habit> positionComparator = (h1, h2) -> Comparator<Habit> positionComparator = (h1, h2) ->
{ {
Integer p1 = h1.getPosition(); Integer p1 = h1.getPosition();
@ -151,7 +159,7 @@ public class MemoryHabitList extends HabitList
if (order == BY_NAME) return nameComparator; if (order == BY_NAME) return nameComparator;
if (order == BY_COLOR) return colorComparator; if (order == BY_COLOR) return colorComparator;
if (order == BY_SCORE) return scoreComparator; if (order == BY_SCORE) return scoreComparator;
if (order == BY_SCORE_ASC) return scoreComparator.reversed(); if (order == BY_SCORE_ASC) return ascendingScoreComparator;
throw new IllegalStateException(); throw new IllegalStateException();
} }

Loading…
Cancel
Save