This commit is contained in:
parent
8380c18543
commit
83a6d70387
|
@ -14,7 +14,7 @@ import java.util.concurrent.FutureTask;
|
||||||
import de.danoeh.antennapod.core.R;
|
import de.danoeh.antennapod.core.R;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.feed.SearchResult;
|
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
|
* Performs search on Feeds and FeedItems
|
||||||
|
@ -76,7 +76,7 @@ public class FeedSearcher {
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Collections.sort(result, new SearchResultValueComparator());
|
Collections.sort(result, new InReverseChronologicalOrder());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue