Selaa lähdekoodia

Merge pull request #4276 from nextcloud/uploader

Check status on transfer update
Andy Scherzinger 5 vuotta sitten
vanhempi
commit
129e9abcc0
1 muutettua tiedostoa jossa 17 lisäystä ja 16 poistoa
  1. 17 16
      src/main/java/com/owncloud/android/files/services/FileUploader.java

+ 17 - 16
src/main/java/com/owncloud/android/files/services/FileUploader.java

@@ -975,24 +975,25 @@ public class FileUploader extends Service
                                        long totalToTransfer, String fileName) {
             String key = buildRemoteName(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath());
             OnDatatransferProgressListener boundListener = mBoundListeners.get(key);
+
             if (boundListener != null) {
                 boundListener.onTransferProgress(progressRate, totalTransferredSoFar,
-                        totalToTransfer, fileName);
-
-                if (MainApp.getAppContext() != null) {
-                    if (mCurrentUpload.isWifiRequired() && !Device.getNetworkType(MainApp.getAppContext()).
-                            equals(JobRequest.NetworkType.UNMETERED)) {
-                        cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
-                                , ResultCode.DELAYED_FOR_WIFI);
-                    } else if (mCurrentUpload.isChargingRequired() &&
-                            !Device.getBatteryStatus(MainApp.getAppContext()).isCharging()) {
-                        cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
-                                , ResultCode.DELAYED_FOR_CHARGING);
-                    } else if (!mCurrentUpload.isIgnoringPowerSaveMode() &&
-                            powerManagementService.isPowerSavingEnabled()) {
-                        cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
-                                , ResultCode.DELAYED_IN_POWER_SAVE_MODE);
-                    }
+                                                 totalToTransfer, fileName);
+            }
+
+            if (MainApp.getAppContext() != null) {
+                if (mCurrentUpload.isWifiRequired() && !Device.getNetworkType(MainApp.getAppContext()).
+                    equals(JobRequest.NetworkType.UNMETERED)) {
+                    cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
+                        , ResultCode.DELAYED_FOR_WIFI);
+                } else if (mCurrentUpload.isChargingRequired() &&
+                    !Device.getBatteryStatus(MainApp.getAppContext()).isCharging()) {
+                    cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
+                        , ResultCode.DELAYED_FOR_CHARGING);
+                } else if (!mCurrentUpload.isIgnoringPowerSaveMode() &&
+                    powerManagementService.isPowerSavingEnabled()) {
+                    cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
+                        , ResultCode.DELAYED_IN_POWER_SAVE_MODE);
                 }
             }
         }