Pārlūkot izejas kodu

refactor: Dedplicate code to handle nonexisting folder

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
Álvaro Brey 2 gadi atpakaļ
vecāks
revīzija
d0d080d400

+ 7 - 14
app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

@@ -257,21 +257,21 @@ public class ReceiveExternalFilesActivity extends FileActivity
         }
 
         initTargetFolder();
+        browseToFolderIfItExists();
+    }
+
+    private void browseToFolderIfItExists() {
         String full_path = generatePath(mParents);
         final OCFile fileByPath = getStorageManager().getFileByPath(full_path);
         if (fileByPath != null) {
             startSyncFolderOperation(fileByPath);
             populateDirectoryList();
         } else {
-            handleNonExistingFolder();
+            browseToRoot();
+            preferences.setLastUploadPath(OCFile.ROOT_PATH);
         }
     }
 
-    private void handleNonExistingFolder() {
-        browseToRoot();
-        preferences.setLastUploadPath(OCFile.ROOT_PATH);
-    }
-
     @Override
     protected void onSaveInstanceState(@NonNull Bundle outState) {
         Log_OC.d(TAG, "onSaveInstanceState() start");
@@ -634,14 +634,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
             super.onBackPressed();
         } else {
             mParents.pop();
-            String full_path = generatePath(mParents);
-            final OCFile fileByPath = getStorageManager().getFileByPath(full_path);
-            if (fileByPath != null) {
-                startSyncFolderOperation(fileByPath);
-                populateDirectoryList();
-            } else {
-                handleNonExistingFolder();
-            }
+            browseToFolderIfItExists();
         }
     }