X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/ff2271a8c531efe4c2602c63934eca568c397510..e4bc3bdadc47c01e88dd1de94a4666d3753ee90e:/src/com/owncloud/android/files/services/FileDownloader.java diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index b89a1c37..f58e563c 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -136,6 +136,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis mPendingDownloads.putIfAbsent(downloadKey, newDownload); newDownload.addDatatransferProgressListener(this); requestedDownloads.add(downloadKey); + sendBroadcastNewDownload(newDownload); } catch (IllegalArgumentException e) { Log.e(TAG, "Not enough information provided in intent: " + e.getMessage()); @@ -273,7 +274,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis /// notify result notifyDownloadResult(mCurrentDownload, downloadResult); - sendFinalBroadcast(mCurrentDownload, downloadResult); + sendBroadcastDownloadFinished(mCurrentDownload, downloadResult); } } @@ -368,18 +369,32 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis /** - * Sends a broadcast in order to the interested activities can update their view + * Sends a broadcast when a download finishes in order to the interested activities can update their view * * @param download Finished download operation * @param downloadResult Result of the download operation */ - private void sendFinalBroadcast(DownloadFileOperation download, RemoteOperationResult downloadResult) { + private void sendBroadcastDownloadFinished(DownloadFileOperation download, RemoteOperationResult downloadResult) { Intent end = new Intent(DOWNLOAD_FINISH_MESSAGE); end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess()); end.putExtra(ACCOUNT_NAME, download.getAccount().name); end.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath()); end.putExtra(EXTRA_FILE_PATH, download.getSavePath()); - sendBroadcast(end); + sendStickyBroadcast(end); + } + + + /** + * Sends a broadcast when a new download is added to the queue. + * + * @param download Added download operation + */ + private void sendBroadcastNewDownload(DownloadFileOperation download) { + Intent added = new Intent(DOWNLOAD_ADDED_MESSAGE); + /*added.putExtra(ACCOUNT_NAME, download.getAccount().name); + added.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());*/ + added.putExtra(EXTRA_FILE_PATH, download.getSavePath()); + sendStickyBroadcast(added); } }