public static final String EXTRA_ACCOUNT = "ACCOUNT";\r
public static final String EXTRA_FILE = "FILE";\r
\r
+ public static final String DOWNLOAD_ADDED_MESSAGE = "DOWNLOAD_ADDED";\r
public static final String DOWNLOAD_FINISH_MESSAGE = "DOWNLOAD_FINISH";\r
public static final String EXTRA_DOWNLOAD_RESULT = "RESULT"; \r
public static final String EXTRA_FILE_PATH = "FILE_PATH";\r
mPendingDownloads.putIfAbsent(downloadKey, newDownload);\r
newDownload.addDatatransferProgressListener(this);\r
requestedDownloads.add(downloadKey);\r
+ sendBroadcastNewDownload(newDownload);\r
\r
} catch (IllegalArgumentException e) {\r
Log.e(TAG, "Not enough information provided in intent: " + e.getMessage());\r
/// notify result\r
notifyDownloadResult(mCurrentDownload, downloadResult);\r
\r
- sendFinalBroadcast(mCurrentDownload, downloadResult);\r
+ sendBroadcastDownloadFinished(mCurrentDownload, downloadResult);\r
}\r
}\r
\r
*/\r
private void saveDownloadedFile() {\r
OCFile file = mCurrentDownload.getFile();\r
- file.setLastSyncDate(System.currentTimeMillis());\r
+ long syncDate = System.currentTimeMillis();\r
+ file.setLastSyncDateForProperties(syncDate);\r
+ file.setLastSyncDateForData(syncDate);\r
file.setModificationTimestamp(mCurrentDownload.getModificationTimestamp());\r
// file.setEtag(mCurrentDownload.getEtag()); // TODO Etag, where available\r
file.setMimetype(mCurrentDownload.getMimeType());\r
\r
\r
/**\r
- * Sends a broadcast in order to the interested activities can update their view\r
+ * Sends a broadcast when a download finishes in order to the interested activities can update their view\r
* \r
* @param download Finished download operation\r
* @param downloadResult Result of the download operation\r
*/\r
- private void sendFinalBroadcast(DownloadFileOperation download, RemoteOperationResult downloadResult) {\r
+ private void sendBroadcastDownloadFinished(DownloadFileOperation download, RemoteOperationResult downloadResult) {\r
Intent end = new Intent(DOWNLOAD_FINISH_MESSAGE);\r
end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess());\r
end.putExtra(ACCOUNT_NAME, download.getAccount().name);\r
end.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());\r
end.putExtra(EXTRA_FILE_PATH, download.getSavePath());\r
- sendBroadcast(end);\r
+ sendStickyBroadcast(end);\r
+ }\r
+ \r
+ \r
+ /**\r
+ * Sends a broadcast when a new download is added to the queue.\r
+ * \r
+ * @param download Added download operation\r
+ */\r
+ private void sendBroadcastNewDownload(DownloadFileOperation download) {\r
+ Intent added = new Intent(DOWNLOAD_ADDED_MESSAGE);\r
+ /*added.putExtra(ACCOUNT_NAME, download.getAccount().name);\r
+ added.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());*/\r
+ added.putExtra(EXTRA_FILE_PATH, download.getSavePath());\r
+ sendStickyBroadcast(added);\r
}\r
\r
}\r