From bbf7cd81a6daae218553a75ba3b984c56acb6635 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Thu, 21 Apr 2016 15:30:04 +1000 Subject: [PATCH] Extract common code to isQueued and isActive. --- .../main/java/org/fdroid/fdroid/net/DownloaderService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java b/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java index f72ec99c5..2b1bcf260 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java +++ b/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java @@ -134,11 +134,9 @@ public class DownloaderService extends Service { if (ACTION_CANCEL.equals(intent.getAction())) { Log.i(TAG, "Removed " + intent); Integer what = QUEUE_WHATS.remove(uriString); - if (what != null && serviceHandler.hasMessages(what)) { - // the URL is in the queue, remove it + if (isQueued(uriString)) { serviceHandler.removeMessages(what); - } else if (downloader != null && TextUtils.equals(uriString, downloader.sourceUrl.toString())) { - // the URL is being downloaded, cancel it + } else if (isActive(uriString)) { downloader.cancelDownload(); } else { Log.e(TAG, "CANCEL called on something not queued or running: " + startId + " " + intent);