From: jabarros Date: Tue, 16 Dec 2014 13:15:46 +0000 (+0100) Subject: Run folder download cancelation in new thread X-Git-Tag: oc-android-1.7.0_signed~23^2~24^2~2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/0c8d508a61de7fe698c1f87e2a8415bea2efb1f0?hp=--cc Run folder download cancelation in new thread --- 0c8d508a61de7fe698c1f87e2a8415bea2efb1f0 diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 12ec4654..2519b6b9 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -95,6 +95,9 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis private NotificationManager mNotificationManager; private NotificationCompat.Builder mNotificationBuilder; private int mLastPercent; + + private Account mAccount; + private OCFile mFile; public static String getDownloadAddedMessage() { @@ -147,20 +150,24 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } else { - Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); - OCFile file = intent.getParcelableExtra(EXTRA_FILE); + mAccount = intent.getParcelableExtra(EXTRA_ACCOUNT); + mFile = intent.getParcelableExtra(EXTRA_FILE); if (ACTION_CANCEL_FILE_DOWNLOAD.equals(intent.getAction())) { - // Cancel the download - cancel(account,file); + new Thread(new Runnable() { + public void run() { + // Cancel the download + cancel(mAccount,mFile); + } + }).start(); } else { AbstractList requestedDownloads = new Vector(); // dvelasco: now this always contains just one element, but that can change in a near future (download of multiple selection) - String downloadKey = buildRemoteName(account, file); + String downloadKey = buildRemoteName(mAccount, mFile); try { - DownloadFileOperation newDownload = new DownloadFileOperation(account, file); + DownloadFileOperation newDownload = new DownloadFileOperation(mAccount, mFile); mPendingDownloads.putIfAbsent(downloadKey, newDownload); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder);