diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java index 8d4a197ad..c61abc168 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java @@ -3,12 +3,13 @@ package de.danoeh.antennapod.core.storage; import android.content.Context; import android.content.Intent; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; import android.text.TextUtils; import android.util.Log; import android.webkit.URLUtil; +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; + import org.apache.commons.io.FilenameUtils; import java.io.File; @@ -31,7 +32,7 @@ import de.danoeh.antennapod.core.util.URLChecker; * Sends download requests to the DownloadService. This class should always be used for starting downloads, * otherwise they won't work correctly. */ -public class DownloadRequester implements FeedFileDownloadStatusRequesterInterface { +public class DownloadRequester implements DownloadStateProvider { private static final String TAG = "DownloadRequester"; private static final String FEED_DOWNLOADPATH = "cache/"; diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedFileDownloadStatusRequesterInterface.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadStateProvider.java similarity index 69% rename from core/src/main/java/de/danoeh/antennapod/core/storage/FeedFileDownloadStatusRequesterInterface.java rename to core/src/main/java/de/danoeh/antennapod/core/storage/DownloadStateProvider.java index b331fc4d7..ece40353f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedFileDownloadStatusRequesterInterface.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadStateProvider.java @@ -4,7 +4,10 @@ import androidx.annotation.NonNull; import de.danoeh.antennapod.core.feed.FeedFile; -public interface FeedFileDownloadStatusRequesterInterface { +/** + * Allow callers to query the states of downloads, but not affect them. + */ +public interface DownloadStateProvider { /** * @return {@code true} if the named feedfile is in the downloads list */ diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculator.java b/core/src/main/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculator.java index 6e7843836..e69a1adf3 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculator.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculator.java @@ -41,11 +41,8 @@ class ItemEnqueuePositionCalculator { private final @NonNull Options options; - /** - * The logic needs to use {@link DownloadRequester#isDownloadingFile(FeedFile)} method only - */ @VisibleForTesting - FeedFileDownloadStatusRequesterInterface requester = DownloadRequester.getInstance(); + DownloadStateProvider downloadStateProvider = DownloadRequester.getInstance(); public ItemEnqueuePositionCalculator(@NonNull Options options) { this.options = options; @@ -100,7 +97,7 @@ class ItemEnqueuePositionCalculator { if (curItem != null && curItem.getMedia() != null && - requester.isDownloadingFile(curItem.getMedia())) { + downloadStateProvider.isDownloadingFile(curItem.getMedia())) { return true; } else { return false; diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculatorTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculatorTest.java index 1331df67d..7b5296e8e 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculatorTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculatorTest.java @@ -186,7 +186,7 @@ public class ItemEnqueuePositionCalculatorTest { // ItemEnqueuePositionCalculator calculator = new ItemEnqueuePositionCalculator(options); MockDownloadRequester mockDownloadRequester = new MockDownloadRequester(); - calculator.requester = mockDownloadRequester; + calculator.downloadStateProvider = mockDownloadRequester; // Setup initial data // A shallow copy, as the test code will manipulate the queue @@ -236,7 +236,7 @@ public class ItemEnqueuePositionCalculatorTest { return item; } - private static class MockDownloadRequester implements FeedFileDownloadStatusRequesterInterface { + private static class MockDownloadRequester implements DownloadStateProvider { private Map downloadingByIds = new HashMap<>();