From e3d8e853376ef12f64948bfd93b036538b00a70f Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Dec 2023 09:54:03 +0100 Subject: [PATCH] Fix FileDownloaderBinder cancelAllDownloadsForAccount Signed-off-by: alperozturk --- .../client/files/downloader/FileDownloadWorker.kt | 11 ++++++----- .../android/operations/DownloadFileOperation.java | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt b/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt index 26fb514d55..94824ee90a 100644 --- a/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt @@ -155,8 +155,8 @@ class FileDownloadWorker( downloadType ) - operation.addDatatransferProgressListener(this) - operation.addDatatransferProgressListener(downloadBinder as FileDownloaderBinder) + operation.addDownloadDataTransferProgressListener(this) + operation.addDownloadDataTransferProgressListener(downloadBinder as FileDownloaderBinder) val putResult = pendingDownloads.putIfAbsent( user?.accountName, file.remotePath, @@ -203,7 +203,7 @@ class FileDownloadWorker( val isAccountExist = accountManager.exists(currentDownload?.user?.toPlatformAccount()) if (!isAccountExist) { - cancelPendingDownloads(currentDownload?.user?.accountName) + removePendingDownload(currentDownload?.user?.accountName) return } @@ -228,7 +228,7 @@ class FileDownloadWorker( } } - private fun cancelPendingDownloads(accountName: String?) { + private fun removePendingDownload(accountName: String?) { pendingDownloads.remove(accountName) } @@ -358,10 +358,11 @@ class FileDownloadWorker( fun cancelAllDownloadsForAccount(accountName: String?) { if (currentDownload?.user?.nameEquals(accountName) == true) { + context.cancelWork(JOB_FILES_DOWNLOAD) currentDownload?.cancel() } - cancelPendingDownloads(accountName) + removePendingDownload(accountName) } fun isDownloading(): Boolean { diff --git a/app/src/main/java/com/owncloud/android/operations/DownloadFileOperation.java b/app/src/main/java/com/owncloud/android/operations/DownloadFileOperation.java index 9da4a78e20..568467654f 100644 --- a/app/src/main/java/com/owncloud/android/operations/DownloadFileOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/DownloadFileOperation.java @@ -260,7 +260,7 @@ public class DownloadFileOperation extends RemoteOperation { } - public void addDatatransferProgressListener (OnDatatransferProgressListener listener) { + public void addDownloadDataTransferProgressListener(OnDatatransferProgressListener listener) { synchronized (dataTransferListeners) { dataTransferListeners.add(listener); }