- /*observerParent.startWatching();
- Log_OC.d(TAG, "Started watching parent file " + parentPath);*/
- }
- // else - the observance can't be started on a file not already down;
- // mDownloadReceiver will get noticed when the download of the file finishes
+ }
+ // else - the observance can't be started on a file not already
+ // down;
+ // mDownloadReceiver will get noticed when the download of the file
+ // finishes
+ }
+ }
+
+ /**
+ * Registers the folder to be observed in which there are changes inside any
+ * file
+ *
+ * @param localPath String representing the folder will be observed
+ * @param account OwnCloud account containing file.
+ */
+ public void addObservedFolder(String localPath, Account account) {
+ Log_OC.v(TAG, "Adding a child file to be watched");
+
+ String parentPath = (new File(localPath)).getParent();
+ OwnCloudFolderObserver observerParent = mObserversFolderMap.get(parentPath);
+ if (observerParent == null) {
+ observerParent = new OwnCloudFolderObserver(parentPath, account, getApplicationContext());
+ mObserversFolderMap.put(parentPath, observerParent);
+ Log_OC.d(TAG, "Observer added for parent folder " + parentPath + "/");
+
+ if (new File(parentPath).exists()) {
+ observerParent.startWatching();
+ Log_OC.d(TAG, "Started watching parent folder " + parentPath + "/");
+ }