Some improvements in synchronization and refresh of directory list
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / activity / FileDisplayActivity.java
index 188d1f0..e0eccf9 100644 (file)
@@ -160,6 +160,8 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                 break;\r
             }\r
             case R.id.startSync: {\r
+                // This could be interesting\r
+                //ContentResolver.cancelSync(null, "org.owncloud");   // cancel the current synchronizations of any other ownCloud account\r
                 Bundle bundle = new Bundle();\r
                 bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
                 ContentResolver.requestSync(\r
@@ -614,29 +616,25 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
             Log.d("FileDisplay", "sync of account " + account_name\r
                     + " is in_progress: " + inProgress);\r
 \r
-            //if (account_name.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)) {  // TODO - probably this check should be added, but won't push it until really tests are done; no time now\r
+            if (account_name.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)) {  \r
             \r
-                /// try to refresh the view with every message received from the FileSyncAdapter; brute, but more user friendly when there are a lot of files in the server\r
-                OCFile currentDir;\r
+                String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH); \r
+                        \r
                 if (mCurrentDir == null)\r
-                    currentDir = mStorageManager.getFileByPath("/");\r
-                else\r
-                    currentDir = mStorageManager.getFileByPath(mCurrentDir.getRemotePath());\r
-                \r
-                if (currentDir != null) {\r
-                    mCurrentDir = currentDir;\r
+                    mCurrentDir = mStorageManager.getFileByPath("/");\r
+\r
+                if (synchFolderRemotePath != null && mCurrentDir != null && mCurrentDir.getRemotePath().equals(synchFolderRemotePath) ) {\r
                     FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager()\r
                             .findFragmentById(R.id.fileList);\r
+                    mCurrentDir = getStorageManager().getFileByPath(synchFolderRemotePath);\r
                     if (fileListFragment != null) {\r
-                        if (!mCurrentDir.equals(fileListFragment.getCurrentFile())) {\r
-                            fileListFragment.listDirectory(mCurrentDir);    // only set the directory in the fragment first time\r
-                        } else\r
-                            fileListFragment.listDirectory();   // enough to show new files in the current directory if they are added after \r
+                        fileListFragment.listDirectory(mCurrentDir);  \r
                     }\r
                 }\r
                 \r
                 setSupportProgressBarIndeterminateVisibility(inProgress);\r
-            //}\r
+                \r
+            }\r
         }\r
     }\r
     \r