From 24092ce465aeb243e657b76ba594da5b7bcfe8db Mon Sep 17 00:00:00 2001 From: tzugen Date: Sun, 17 Oct 2021 10:19:17 +0200 Subject: [PATCH] Remove unneccessary call to checkDownloads() which were interferring with AutoPlay somehow. --- .../moire/ultrasonic/service/Downloader.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/Downloader.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/Downloader.kt index 17ec255d..10ec0a36 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/Downloader.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/Downloader.kt @@ -162,10 +162,14 @@ class Downloader( } if (listChanged) { - observableList.postValue(downloads) + updateLiveData() } } + private fun updateLiveData() { + observableList.postValue(downloads) + } + private fun startDownloadOnService(task: DownloadFile) { MediaPlayerService.executeOnStartedMediaPlayerService { task.download() @@ -254,12 +258,14 @@ class Downloader( // Cancel all active downloads with a high priority for (download in activelyDownloading) { - if (download.priority < 100) + if (download.priority < 100) { download.cancelDownload() + activelyDownloading.remove(download) + } } playlistUpdateRevision++ - checkDownloads() + updateLiveData() } @Synchronized @@ -269,18 +275,21 @@ class Downloader( // Cancel all active downloads with a low priority for (download in activelyDownloading) { - if (download.priority >= 100) + if (download.priority >= 100) { download.cancelDownload() + activelyDownloading.remove(download) + } } } @Synchronized fun clearActiveDownloads() { - // Cancel all active downloads with a low priority + // Cancel all active downloads for (download in activelyDownloading) { download.cancelDownload() } - checkDownloads() + activelyDownloading.clear() + updateLiveData() } @Synchronized