diff options
Diffstat (limited to 'app/src/main/java/github')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/DownloadService.java | 8 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java | 2 |
2 files changed, 9 insertions, 1 deletions
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 4b8d9db3..e1b3d0ae 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1036,6 +1036,14 @@ public class DownloadService extends Service { return temp; } + public synchronized List<DownloadFile> getRecentDownloads() { + int from = Math.max(currentPlayingIndex - 10, 0); + int to = Math.min(currentPlayingIndex + 20, downloadList.size() - 1); + List<DownloadFile> temp = downloadList.subList(from, to); + temp.addAll(backgroundDownloadList); + return temp; + } + public List<DownloadFile> getBackgroundDownloads() { return backgroundDownloadList; } diff --git a/app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java b/app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java index ac8fa72a..f160e176 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java +++ b/app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java @@ -151,7 +151,7 @@ public class CacheCleaner { private Set<File> findUndeletableFiles() { Set<File> undeletable = new HashSet<File>(5); - for (DownloadFile downloadFile : downloadService.getDownloads()) { + for (DownloadFile downloadFile : downloadService.getRecentDownloads()) { undeletable.add(downloadFile.getPartialFile()); undeletable.add(downloadFile.getCompleteFile()); } |