- private static String TAG = "FileObserverService";
- private static List<OwnCloudFileObserver> mObservers;
- private static List<DownloadCompletedReceiver> mDownloadReceivers;
- private static Object mReceiverListLock = new Object();
- private IBinder mBinder = new LocalBinder();
+ private static String TAG = FileObserverService.class.getSimpleName();
+
+ private Map<String, OwnCloudFolderObserver> mFolderObserversMap;
+ private DownloadCompletedReceiver mDownloadReceiver;
+
+ /**
+ * Factory method to create intents that allow to start an
+ * ACTION_START_OBSERVE command.
+ *
+ * @param context Android context of the caller component.
+ * @return Intent that starts a command ACTION_START_OBSERVE when
+ * {@link Context#startService(Intent)} is called.
+ */
+ public static Intent makeInitIntent(Context context) {
+ Intent i = new Intent(context, FileObserverService.class);
+ i.setAction(ACTION_START_OBSERVE);
+ return i;
+ }
+
+ /**
+ * Factory method to create intents that allow to start or stop the
+ * observance of a file.
+ *
+ * @param context Android context of the caller component.
+ * @param file OCFile to start or stop to watch.
+ * @param account OC account containing file.
+ * @param watchIt 'True' creates an intent to watch, 'false' an intent to
+ * stop watching.
+ * @return Intent to start or stop the observance of a file through a call
+ * to {@link Context#startService(Intent)}.
+ */
+ public static Intent makeObservedFileIntent(
+ Context context, OCFile file, Account account, boolean watchIt) {
+ Intent intent = new Intent(context, FileObserverService.class);
+ intent.setAction(watchIt ? FileObserverService.ACTION_ADD_OBSERVED_FILE
+ : FileObserverService.ACTION_DEL_OBSERVED_FILE);
+ intent.putExtra(FileObserverService.ARG_FILE, file);
+ intent.putExtra(FileObserverService.ARG_ACCOUNT, account);
+ return intent;
+ }