Browse Source

Overload downloadFile functions

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 year ago
parent
commit
412319276d

+ 48 - 0
app/src/main/java/com/nextcloud/client/files/downloader/FilesDownloadHelper.kt

@@ -41,6 +41,54 @@ class FilesDownloadHelper {
         MainApp.getAppComponent().inject(this)
     }
 
+    fun downloadFile(user: User, ocFile: OCFile) {
+        backgroundJobManager.startFilesDownloadJob(
+            user,
+            ocFile,
+            "",
+            null,
+            "",
+            "",
+            null
+        )
+    }
+
+    fun downloadFile(user: User, ocFile: OCFile, behaviour: String) {
+        backgroundJobManager.startFilesDownloadJob(
+            user,
+            ocFile,
+            behaviour,
+            null,
+            "",
+            "",
+            null
+        )
+    }
+
+    fun downloadFile(user: User, ocFile: OCFile, downloadType: DownloadType) {
+        backgroundJobManager.startFilesDownloadJob(
+            user,
+            ocFile,
+            "",
+            downloadType,
+            "",
+            "",
+            null
+        )
+    }
+
+    fun downloadFile(user: User, ocFile: OCFile, conflictUploadId: Long) {
+        backgroundJobManager.startFilesDownloadJob(
+            user,
+            ocFile,
+            "",
+            null,
+            "",
+            "",
+            conflictUploadId
+        )
+    }
+
     fun downloadFile(
         user: User,
         ocFile: OCFile,

+ 1 - 5
app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt

@@ -114,11 +114,7 @@ class FilesExportWork(
         FilesDownloadHelper().downloadFile(
             user,
             ocFile,
-            behaviour = "",
-            packageName = "",
-            activityName = "",
-            conflictUploadId = 0L,
-            downloadType = DownloadType.EXPORT
+            DownloadType.EXPORT
         )
     }
 

+ 1 - 6
app/src/main/java/com/owncloud/android/operations/SynchronizeFileOperation.java

@@ -320,12 +320,7 @@ public class SynchronizeFileOperation extends SyncOperation {
 
         downloadHelper.downloadFile(
             mUser,
-            file,
-            "",
-            null,
-            "",
-            "",
-            null);
+            file);
 
         mTransferWasRequested = true;
     }

+ 1 - 8
app/src/main/java/com/owncloud/android/operations/SynchronizeFolderOperation.java

@@ -454,14 +454,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
 
                 FilesDownloadHelper downloadHelper = new FilesDownloadHelper();
 
-                downloadHelper.downloadFile(
-                    user,
-                    file,
-                    "",
-                    null,
-                    "",
-                    "",
-                    null);
+                downloadHelper.downloadFile(user, file);
             }
         }
     }

+ 3 - 7
app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt

@@ -116,13 +116,9 @@ class ConflictsResolveActivity : FileActivity(), OnConflictDecisionMadeListener
                     // Overwrite local file
                     file?.let {
                         FilesDownloadHelper().downloadFile(
-                            user = getUser().orElseThrow { RuntimeException() },
-                            ocFile = file,
-                            conflictUploadId = conflictUploadId,
-                            behaviour = "",
-                            packageName = "",
-                            activityName = "",
-                            downloadType = null
+                            getUser().orElseThrow { RuntimeException() },
+                            file,
+                            conflictUploadId
                         )
                     }
                 } else {

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java

@@ -236,7 +236,7 @@ public abstract class FileActivity extends DrawerActivity
 
         mDownloadServiceConnection = newTransferenceServiceConnection();
         if (mDownloadServiceConnection != null && user != null) {
-            new FilesDownloadHelper().downloadFile(user, mFile, "", null, "", "", null);
+            new FilesDownloadHelper().downloadFile(user, mFile);
         }
         mUploadServiceConnection = newTransferenceServiceConnection();
         if (mUploadServiceConnection != null) {

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1885,7 +1885,7 @@ public class FileDisplayActivity extends FileActivity
         User user = getUser().orElseThrow(RuntimeException::new);
         //if (!mWaitingToPreview.isDownloading()) {
         if (!mDownloaderBinder.isDownloading(user, mWaitingToPreview)) {
-            new FilesDownloadHelper().downloadFile(user, mWaitingToPreview, "", null, "", "", null);
+            new FilesDownloadHelper().downloadFile(user, mWaitingToPreview);
         }
     }
 

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -413,7 +413,7 @@ public class PreviewImageActivity extends FileActivity implements
 
         } else if (!mDownloaderBinder.isDownloading(getUserAccountManager().getUser(), file)) {
             final User user = getUser().orElseThrow(RuntimeException::new);
-            new FilesDownloadHelper().downloadFile(user, file, downloadBehaviour, null, "", "", null);
+            new FilesDownloadHelper().downloadFile(user, file, downloadBehaviour);
         }
     }
 

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java

@@ -479,7 +479,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
                                                                     backgroundJobManager);
         } else if (itemId == R.id.action_download_file) {
             if (!containerActivity.getFileDownloaderBinder().isDownloading(user, getFile())) {
-                new FilesDownloadHelper().downloadFile(user, getFile(), "", null, "", "", null);
+                new FilesDownloadHelper().downloadFile(user, getFile());
             }
         }
     }