Fixed bug: when a file is checked as 'keep in sync' and the immediate synchronization...
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / fragment / FileDetailFragment.java
index 01fc186..53e0630 100644 (file)
@@ -292,7 +292,7 @@ public class FileDetailFragment extends SherlockFragment implements
                     }\r
                     \r
                 } else {\r
                     }\r
                     \r
                 } else {\r
-                    mLastRemoteOperation = new SynchronizeFileOperation(mFile.getRemotePath(), fdsm, mAccount, true, false, getActivity());\r
+                    mLastRemoteOperation = new SynchronizeFileOperation(mFile, fdsm, mAccount, true, false, getActivity());\r
                     WebdavClient wc = OwnCloudClientUtils.createOwnCloudClient(mAccount, getSherlockActivity().getApplicationContext());\r
                     mLastRemoteOperation.execute(wc, this, mHandler);\r
                 \r
                     WebdavClient wc = OwnCloudClientUtils.createOwnCloudClient(mAccount, getSherlockActivity().getApplicationContext());\r
                     mLastRemoteOperation.execute(wc, this, mHandler);\r
                 \r
@@ -309,19 +309,6 @@ public class FileDetailFragment extends SherlockFragment implements
                 mFile.setKeepInSync(cb.isChecked());\r
                 fdsm.saveFile(mFile);\r
                 \r
                 mFile.setKeepInSync(cb.isChecked());\r
                 fdsm.saveFile(mFile);\r
                 \r
-                /* NOT HERE\r
-                 * now that FileObserverService is involved, the easiest way to coordinate it with the download service\r
-                 * in every possible case is let the FileObserverService decide if the download should be started at\r
-                 * this moment or not\r
-                 * \r
-                 * see changes at FileObserverService#addObservedFile\r
-                 \r
-                   if (mFile.keepInSync()) {\r
-                    onClick(getView().findViewById(R.id.fdDownloadBtn));\r
-                } else {\r
-                    mContainerActivity.onFileStateChanged();    // put inside 'else' to not call it twice (here, and in the virtual click on fdDownloadBtn)\r
-                }*/\r
-                \r
                 /// register the OCFile instance in the observer service to monitor local updates;\r
                 /// if necessary, the file is download \r
                 Intent intent = new Intent(getActivity().getApplicationContext(),\r
                 /// register the OCFile instance in the observer service to monitor local updates;\r
                 /// if necessary, the file is download \r
                 Intent intent = new Intent(getActivity().getApplicationContext(),\r
@@ -335,7 +322,9 @@ public class FileDetailFragment extends SherlockFragment implements
                 Log.e(TAG, "starting observer service");\r
                 getActivity().startService(intent);\r
                 \r
                 Log.e(TAG, "starting observer service");\r
                 getActivity().startService(intent);\r
                 \r
-                mContainerActivity.onFileStateChanged();                \r
+                if (mFile.keepInSync()) {\r
+                    onClick(getView().findViewById(R.id.fdDownloadBtn));    // force an immediate synchronization\r
+                }\r
                 break;\r
             }\r
             case R.id.fdRenameBtn: {\r
                 break;\r
             }\r
             case R.id.fdRenameBtn: {\r