Fixed behaviour when user enters in a folder deleted in the server before the app...
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / FileDisplayActivity.java
index 5eba7dc..f886732 100644 (file)
@@ -594,23 +594,22 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
     @Override
     public void onBackPressed() {
 
     @Override
     public void onBackPressed() {
-        if (!mSyncInProgress) {
-            OCFileListFragment listOfFiles = getListOfFilesFragment(); 
-            if (mDualPane || getSecondFragment() == null) {
-                if (listOfFiles != null) {  // should never be null, indeed
-                    if (mDirectories.getCount() <= 1) {
-                        finish();
-                        return;
-                    }
-                    popDirname();
-                    listOfFiles.onBrowseUp();
-                }
-            }
+        OCFileListFragment listOfFiles = getListOfFilesFragment(); 
+        if (mDualPane || getSecondFragment() == null) {
             if (listOfFiles != null) {  // should never be null, indeed
             if (listOfFiles != null) {  // should never be null, indeed
-                setFile(listOfFiles.getCurrentFile());
+                if (mDirectories.getCount() <= 1) {
+                    finish();
+                    return;
+                }
+                popDirname();
+                listOfFiles.onBrowseUp();
             }
             }
-            cleanSecondFragment();
         }
         }
+        if (listOfFiles != null) {  // should never be null, indeed
+            setFile(listOfFiles.getCurrentFile());
+        }
+        cleanSecondFragment();
+
     }
 
     @Override
     }
 
     @Override
@@ -652,19 +651,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
 
     @Override
 
 
     @Override
-    protected void onStart() {
-        super.onStart();
-        Log_OC.e(TAG, "onStart() start");
-        
-        // Update the sync operation
-        if (mSyncInProgress){
-        }
-        
-        Log_OC.e(TAG, "onStart() end");
-    }
-
-
-    @Override
     protected void onPause() {
         super.onPause();
         Log_OC.e(TAG, "onPause() start");
     protected void onPause() {
         super.onPause();
         Log_OC.e(TAG, "onPause() start");
@@ -894,15 +880,19 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
                 if ((synchFolderRemotePath != null && currentDir != null && (currentDir.getRemotePath().equals(synchFolderRemotePath)))
                         || fillBlankRoot ) {
 
                 if ((synchFolderRemotePath != null && currentDir != null && (currentDir.getRemotePath().equals(synchFolderRemotePath)))
                         || fillBlankRoot ) {
-                    if (!fillBlankRoot) 
-                        currentDir = getStorageManager().getFileByPath(synchFolderRemotePath);
-                    OCFileListFragment fileListFragment = getListOfFilesFragment();
-                    if (fileListFragment != null) {
-                        fileListFragment.listDirectory(currentDir);
-                        
+                    if (synchResult == null || synchResult.isSuccess()) {
+                        if (!fillBlankRoot) 
+                            currentDir = getStorageManager().getFileByPath(synchFolderRemotePath);
+                        if (currentDir != null) {
+                            OCFileListFragment fileListFragment = getListOfFilesFragment();
+                            if (fileListFragment != null) {
+                                fileListFragment.listDirectory(currentDir);
+                                
+                            }
+                            if (getSecondFragment() == null)
+                                setFile(currentDir);
+                        }
                     }
                     }
-                    if (getSecondFragment() == null)
-                        setFile(currentDir);
                 }
                 
                 setSupportProgressBarIndeterminateVisibility(inProgress);
                 }
                 
                 setSupportProgressBarIndeterminateVisibility(inProgress);
@@ -1073,7 +1063,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
         if (chosenFile == null || mDualPane) {
             // only list of files - set for browsing through folders
             OCFile currentDir = getCurrentDir();
         if (chosenFile == null || mDualPane) {
             // only list of files - set for browsing through folders
             OCFile currentDir = getCurrentDir();
-            actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0 && !mSyncInProgress);
+            actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0);
             actionBar.setDisplayShowTitleEnabled(false);
             actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
             actionBar.setListNavigationCallbacks(mDirectories, this);   // assuming mDirectories is updated
             actionBar.setDisplayShowTitleEnabled(false);
             actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
             actionBar.setListNavigationCallbacks(mDirectories, this);   // assuming mDirectories is updated
@@ -1371,7 +1361,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
                 // Create directory
                 path += newDirectoryName + OCFile.PATH_SEPARATOR;
 
                 // Create directory
                 path += newDirectoryName + OCFile.PATH_SEPARATOR;
-                RemoteOperation operation = new CreateFolderOperation(path, getCurrentDir().getFileId(), mStorageManager);
+                RemoteOperation operation = new CreateFolderOperation(path, false, mStorageManager);
                 operation.execute(  getAccount(), 
                         FileDisplayActivity.this, 
                         FileDisplayActivity.this, 
                 operation.execute(  getAccount(), 
                         FileDisplayActivity.this, 
                         FileDisplayActivity.this,