From cabe1a0f66eb00cf1e73b03f0f27b19eb78cf6dc Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Wed, 11 Nov 2020 22:43:27 +0100 Subject: [PATCH] Fixed comparator method contract when date is null --- .../core/util/comparator/FeedItemPubdateComparator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/FeedItemPubdateComparator.java b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/FeedItemPubdateComparator.java index ad81a1d17..766986bed 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/FeedItemPubdateComparator.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/FeedItemPubdateComparator.java @@ -14,8 +14,12 @@ public class FeedItemPubdateComparator implements Comparator { */ @Override public int compare(FeedItem lhs, FeedItem rhs) { - if (rhs.getPubDate() == null || lhs.getPubDate() == null) { + if (rhs.getPubDate() == null && lhs.getPubDate() == null) { return 0; + } else if (rhs.getPubDate() == null) { + return 1; + } else if (lhs.getPubDate() == null) { + return -1; } return rhs.getPubDate().compareTo(lhs.getPubDate()); }