Browse Source

The app goes directly to root folder when the current folder does not exist anymore after refreshing with server

David A. Velasco 11 năm trước cách đây
mục cha
commit
ec85b4225e

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

@@ -881,7 +881,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
                                     String.format(getString(R.string.sync_current_folder_was_removed), mDirectories.getItem(0)), 
                                     Toast.LENGTH_LONG)
                         .show();
-                    onBackPressed();
+                    jumpToRoot();
                     
                 } else {
                     if (currentFile == null && !getFile().isDirectory()) {
@@ -978,6 +978,21 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
     }
 
 
+    public void jumpToRoot() {
+        OCFileListFragment listOfFiles = getListOfFilesFragment(); 
+        if (listOfFiles != null) {  // should never be null, indeed
+            while (mDirectories.getCount() > 1) {
+                popDirname();
+            }
+            OCFile root = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
+            listOfFiles.listDirectory(root);
+            setFile(listOfFiles.getCurrentFile());
+            startSyncFolderOperation(root);
+        }
+        cleanSecondFragment();
+    }
+
+
     /**
      * {@inheritDoc}
      *