mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-23 07:25:25 +01:00
Fix the smart shuffle spread calculation
We want to ensure that the total spread is divisible by all feed sizes, so the modulo calculation needs to divide spread by the feed size, not the other way round as is done currently. In addition, this ensures the per-feed spread is never 0 (so the degenerate case is equivalent to the old smart shuffle). Signed-off-by: Stephen Kitt <steve@sk2.org>
This commit is contained in:
parent
d7f0f95ada
commit
7ae3934794
@ -164,7 +164,7 @@ public class QueueSorter {
|
||||
Collections.sort(feedItems, itemComparator);
|
||||
if (spread == 0) {
|
||||
spread = feedItems.size();
|
||||
} else if (feedItems.size() % spread != 0){
|
||||
} else if (spread % feedItems.size() != 0){
|
||||
spread *= feedItems.size();
|
||||
}
|
||||
}
|
||||
@ -180,6 +180,9 @@ public class QueueSorter {
|
||||
Map<Long, List<FeedItem>> spreadItems = new HashMap<>();
|
||||
for (List<FeedItem> feedItems : feeds) {
|
||||
long thisSpread = spread / feedItems.size();
|
||||
if (thisSpread == 0) {
|
||||
thisSpread = 1;
|
||||
}
|
||||
// Starting from 0 ensures we front-load, so the queue starts with one episode from
|
||||
// each feed in the queue
|
||||
long itemSpread = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user