diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index 77bc25169..67a0f36fe 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1083,7 +1083,7 @@ public synchronized List getDownloads() { public synchronized List getRecentDownloads() { int from = Math.max(currentPlayingIndex - 10, 0); - int songsToKeep = Math.max(Util.getPreloadCount(this), 20); + int songsToKeep = Math.min(Math.max(Util.getPreloadCount(this), 20), downloadList.size()); int to = Math.min(currentPlayingIndex + songsToKeep, Math.max(downloadList.size() - 1, 0)); List temp = downloadList.subList(from, to); temp.addAll(backgroundDownloadList);