+ if (file.isDirectory()) {\r
+ // this can be slow if there are many downloads :(\r
+ Iterator<String> it = mPendingDownloads.keySet().iterator();\r
+ boolean found = false;\r
+ while (it.hasNext() && !found) {\r
+ found = it.next().startsWith(targetKey);\r
+ }\r
+ return found;\r
+ } else {\r
+ return (mPendingDownloads.containsKey(targetKey));\r
+ }\r
+ }\r
+ }\r
+\r
+ \r
+ /**\r
+ * Adds a listener interested in the progress of the download for a concrete file.\r
+ * \r
+ * @param listener Object to notify about progress of transfer. \r
+ * @param account ownCloud account holding the file of interest.\r
+ * @param file {@link OCfile} of interest for listener. \r
+ */\r
+ public void addDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {\r
+ if (account == null || file == null || listener == null) return;\r
+ String targetKey = buildRemoteName(account, file);\r
+ mBoundListeners.put(targetKey, listener);\r
+ }\r
+ \r
+ \r
+ \r
+ /**\r
+ * Removes a listener interested in the progress of the download for a concrete file.\r
+ * \r
+ * @param listener Object to notify about progress of transfer. \r
+ * @param account ownCloud account holding the file of interest.\r
+ * @param file {@link OCfile} of interest for listener. \r
+ */\r
+ public void removeDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {\r
+ if (account == null || file == null || listener == null) return;\r
+ String targetKey = buildRemoteName(account, file);\r
+ if (mBoundListeners.get(targetKey) == listener) {\r
+ mBoundListeners.remove(targetKey);\r