use of com.fsck.k9.fragment.MessageListFragmentComparators.ReverseIdComparator in project k-9 by k9mail.
the class MessageListFragment method getComparator.
/**
* @return The comparator to use to display messages in an ordered
* fashion. Never {@code null}.
*/
private Comparator<Cursor> getComparator() {
final List<Comparator<Cursor>> chain = new ArrayList<>(3);
// Add the specified comparator
final Comparator<Cursor> comparator = SORT_COMPARATORS.get(sortType);
if (sortAscending) {
chain.add(comparator);
} else {
chain.add(new ReverseComparator<>(comparator));
}
// Add the date comparator if not already specified
if (sortType != SortType.SORT_DATE && sortType != SortType.SORT_ARRIVAL) {
final Comparator<Cursor> dateComparator = SORT_COMPARATORS.get(SortType.SORT_DATE);
if (sortDateAscending) {
chain.add(dateComparator);
} else {
chain.add(new ReverseComparator<>(dateComparator));
}
}
// Add the id comparator
chain.add(new ReverseIdComparator());
// Build the comparator chain
return new ComparatorChain<>(chain);
}
Aggregations