Remove unneccessary call to checkDownloads() which were interferring with AutoPlay somehow.

This commit is contained in:
tzugen 2021-10-17 10:19:17 +02:00
parent 6f676d20b0
commit 24092ce465
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
1 changed files with 15 additions and 6 deletions

View File

@ -162,10 +162,14 @@ class Downloader(
} }
if (listChanged) { if (listChanged) {
observableList.postValue(downloads) updateLiveData()
} }
} }
private fun updateLiveData() {
observableList.postValue(downloads)
}
private fun startDownloadOnService(task: DownloadFile) { private fun startDownloadOnService(task: DownloadFile) {
MediaPlayerService.executeOnStartedMediaPlayerService { MediaPlayerService.executeOnStartedMediaPlayerService {
task.download() task.download()
@ -254,12 +258,14 @@ class Downloader(
// Cancel all active downloads with a high priority // Cancel all active downloads with a high priority
for (download in activelyDownloading) { for (download in activelyDownloading) {
if (download.priority < 100) if (download.priority < 100) {
download.cancelDownload() download.cancelDownload()
activelyDownloading.remove(download)
}
} }
playlistUpdateRevision++ playlistUpdateRevision++
checkDownloads() updateLiveData()
} }
@Synchronized @Synchronized
@ -269,18 +275,21 @@ class Downloader(
// Cancel all active downloads with a low priority // Cancel all active downloads with a low priority
for (download in activelyDownloading) { for (download in activelyDownloading) {
if (download.priority >= 100) if (download.priority >= 100) {
download.cancelDownload() download.cancelDownload()
activelyDownloading.remove(download)
}
} }
} }
@Synchronized @Synchronized
fun clearActiveDownloads() { fun clearActiveDownloads() {
// Cancel all active downloads with a low priority // Cancel all active downloads
for (download in activelyDownloading) { for (download in activelyDownloading) {
download.cancelDownload() download.cancelDownload()
} }
checkDownloads() activelyDownloading.clear()
updateLiveData()
} }
@Synchronized @Synchronized