diff options
author | alimemonzx <44647595+alimemonzx@users.noreply.github.com> | 2019-05-28 19:44:18 +0500 |
---|---|---|
committer | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-05-28 16:44:18 +0200 |
commit | 83a6d70387e8df95e04f198ef99f992aef674413 (patch) | |
tree | d9beb1655eefe5c9e941517715b26e6fb808ab6d | |
parent | 8380c1854333c86d8677ad0197e42762b80d6c18 (diff) | |
download | AntennaPod-83a6d70387e8df95e04f198ef99f992aef674413.zip |
bugfix #3009 - Podcast's feed search results listed in an odd order (#3128)
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java | 4 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/comparator/InReverseChronologicalOrder.java | 21 |
2 files changed, 23 insertions, 2 deletions
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<SearchResult> { + /** + * 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; + } +} |