From: masensio Date: Fri, 20 Feb 2015 09:23:46 +0000 (+0100) Subject: New method in IndexesForest: remove(Account account). Use this method for cancelling... X-Git-Tag: oc-android-1.7.1_signed^2~40^2~5 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/0f7ea542c9b657ba6ad335cd5003901b6ab35385?hp=--cc New method in IndexesForest: remove(Account account). Use this method for cancelling downloads --- 0f7ea542c9b657ba6ad335cd5003901b6ab35385 diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 67cbc599..64eea6be 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -671,22 +671,6 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis */ private void cancelDownloadsForAccount(Account account) { // Cancel pending downloads - ConcurrentMap downloadsAccount = mPendingDownloads.get(account); - Iterator it = downloadsAccount.keySet().iterator(); - Log_OC.d(TAG, "Number of pending downloads= " + downloadsAccount.size()); - DownloadFileOperation download; - while (it.hasNext()) { - String key = it.next(); - Log_OC.d(TAG, "download CANCELLED " + key); - if (key.startsWith(account.name)) { - synchronized (mPendingDownloads) { - download = mPendingDownloads.get(key); - if (download != null) { - String remotePath = download.getRemotePath(); - mPendingDownloads.remove(account, remotePath); - } - } - } - } + mPendingDownloads.remove(account); } } diff --git a/src/com/owncloud/android/files/services/IndexedForest.java b/src/com/owncloud/android/files/services/IndexedForest.java index 66c2d437..1343a8c1 100644 --- a/src/com/owncloud/android/files/services/IndexedForest.java +++ b/src/com/owncloud/android/files/services/IndexedForest.java @@ -213,17 +213,19 @@ public class IndexedForest { } - public ConcurrentMap> get(Account account){ - ConcurrentMap> accountMap = new ConcurrentHashMap>(); + /** + * Remove the elements that contains account as a part of its key + * @param account + */ + public void remove(Account account){ Iterator it = mMap.keySet().iterator(); while (it.hasNext()) { String key = it.next(); Log_OC.d("IndexedForest", "Number of pending downloads= " + mMap.size()); if (key.startsWith(account.name)) { - accountMap.putIfAbsent(key, mMap.get(key)); + mMap.remove(key); } } - return accountMap; } /**