diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java index 4093c41a5..c6620a90e 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java @@ -14,7 +14,7 @@ import java.util.concurrent.FutureTask; import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.SearchResult; -import de.danoeh.antennapod.core.util.comparator.SearchResultValueComparator; +import de.danoeh.antennapod.core.util.comparator.InReverseChronologicalOrder; /** * Performs search on Feeds and FeedItems @@ -76,7 +76,7 @@ public class FeedSearcher { } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } - Collections.sort(result, new SearchResultValueComparator()); + Collections.sort(result, new InReverseChronologicalOrder()); return result; } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/InReverseChronologicalOrder.java b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/InReverseChronologicalOrder.java new file mode 100644 index 000000000..80246af8f --- /dev/null +++ b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/InReverseChronologicalOrder.java @@ -0,0 +1,21 @@ +package de.danoeh.antennapod.core.util.comparator; + +import java.util.Comparator; + +import de.danoeh.antennapod.core.feed.FeedItem; +import de.danoeh.antennapod.core.feed.SearchResult; + +public class InReverseChronologicalOrder implements Comparator { + /** + * Compare items and sort it on chronological order. + */ + @Override + public int compare(SearchResult o1, SearchResult o2) { + if ((o1.getComponent() instanceof FeedItem) && (o2.getComponent() instanceof FeedItem)) { + FeedItem item1 = (FeedItem) o1.getComponent(); + FeedItem item2 = (FeedItem) o2.getComponent(); + return item2.getPubDate().compareTo(item1.getPubDate()); + } + return 0; + } +}