From 361f73ffa001fb6477683eee7f4c23932a234f74 Mon Sep 17 00:00:00 2001 From: Daniel Bowman Date: Sat, 20 Oct 2018 18:38:26 +0100 Subject: Fix a crash on getRecentDownloads if playlist is empty --- app/src/main/java/github/daneren2005/dsub/service/DownloadService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/github/daneren2005') 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 6c3cfbd7..fc2bc7fc 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1060,7 +1060,7 @@ public class DownloadService extends Service { public synchronized List getRecentDownloads() { int from = Math.max(currentPlayingIndex - 10, 0); int songsToKeep = Math.max(Util.getPreloadCount(this), 20); - int to = Math.min(currentPlayingIndex + songsToKeep, downloadList.size() - 1); + int to = Math.min(currentPlayingIndex + songsToKeep, Math.max(downloadList.size() - 1, 0)); List temp = downloadList.subList(from, to); temp.addAll(backgroundDownloadList); return temp; -- cgit v1.2.3