- AbstractList<String> requestedDownloads = new Vector<String>(); // dvelasco: now this always contains just one element, but that can change in a near future (download of multiple selection)
- String downloadKey = buildRemoteName(mAccount, mFile);
- try {
- DownloadFileOperation newDownload = new DownloadFileOperation(mAccount, mFile);
- mPendingDownloads.putIfAbsent(downloadKey, newDownload);
- newDownload.addDatatransferProgressListener(this);
- newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder);
- requestedDownloads.add(downloadKey);
- sendBroadcastNewDownload(newDownload);
-
- } catch (IllegalArgumentException e) {
- Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage());
- return START_NOT_STICKY;
- }
+ AbstractList<String> requestedDownloads = new Vector<String>();
+ try {
+ DownloadFileOperation newDownload = new DownloadFileOperation(account, file);
+ newDownload.addDatatransferProgressListener(this);
+ newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder);
+ Pair<String, String> putResult = mPendingDownloads.putIfAbsent(
+ account, file.getRemotePath(), newDownload
+ );
+ String downloadKey = putResult.first;
+ requestedDownloads.add(downloadKey);
+ /*Log_OC.v(
+ "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
+ "Download on " + file.getRemotePath() + " added to queue"
+ );*/
+
+ // Store file on db with state 'downloading'
+ /*
+ TODO - check if helps with UI responsiveness,
+ letting only folders use FileDownloaderBinder to check
+ FileDataStorageManager storageManager =
+ new FileDataStorageManager(account, getContentResolver());
+ file.setDownloading(true);
+ storageManager.saveFile(file);
+ */
+
+ sendBroadcastNewDownload(newDownload, putResult.second);
+
+ } catch (IllegalArgumentException e) {
+ Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage());
+ return START_NOT_STICKY;
+ }