From: David A. Velasco Date: Wed, 7 Jan 2015 17:23:53 +0000 (+0100) Subject: First try X-Git-Tag: oc-android-1.7.0_signed~23^2~15^2~4 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/14bbe5bf01b8983de8011f217356b40d912bd4a1?ds=inline;hp=--cc First try --- 14bbe5bf01b8983de8011f217356b40d912bd4a1 diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index db806913..eb870e1d 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -96,9 +96,6 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis private NotificationCompat.Builder mNotificationBuilder; private int mLastPercent; - private Account mAccount; - private OCFile mFile; - public static String getDownloadAddedMessage() { return FileDownloader.class.getName().toString() + DOWNLOAD_ADDED_MESSAGE; @@ -150,24 +147,24 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } else { - mAccount = intent.getParcelableExtra(EXTRA_ACCOUNT); - mFile = intent.getParcelableExtra(EXTRA_FILE); + final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); + final OCFile file = intent.getParcelableExtra(EXTRA_FILE); if (ACTION_CANCEL_FILE_DOWNLOAD.equals(intent.getAction())) { new Thread(new Runnable() { public void run() { // Cancel the download - cancel(mAccount,mFile); + cancel(account, file); } }).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(mAccount, mFile); + String downloadKey = buildRemoteName(account, file); try { - DownloadFileOperation newDownload = new DownloadFileOperation(mAccount, mFile); + DownloadFileOperation newDownload = new DownloadFileOperation(account, file); mPendingDownloads.putIfAbsent(downloadKey, newDownload); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder); diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index 0dee54f9..8bdc55e0 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -165,6 +165,11 @@ public class SynchronizeFolderOperation extends SyncOperation { sendBroadcastForNotifyingUIUpdate(result.isSuccess()); } } + + if (mCancellationRequested.get()) { + throw new OperationCancelledException(); + } + } catch (OperationCancelledException e) { result = new RemoteOperationResult(e); @@ -172,6 +177,14 @@ public class SynchronizeFolderOperation extends SyncOperation { for (SyncOperation synchOp: mFoldersToWalkDown) { ((SynchronizeFolderOperation) synchOp).cancel(); } + + /// cancellation of download needs to be done separately in any case; a SynchronizeFolderOperation + // may finish much sooner than the real download of the files in the folder + Intent intent = new Intent(mContext, FileDownloader.class); + intent.setAction(FileDownloader.ACTION_CANCEL_FILE_DOWNLOAD); + intent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount); + intent.putExtra(FileDownloader.EXTRA_FILE, mLocalFolder); + mContext.startService(intent); } return result;