summaryrefslogtreecommitdiff
path: root/net/download/service-interface
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-03-29 17:45:14 +0100
committerGitHub <noreply@github.com>2024-03-29 17:45:14 +0100
commit6f3a9b16764a57e43994ccbeeada5224dee93f44 (patch)
tree24bd2a3ed120dd61b009e5a2b5b9a1c550579997 /net/download/service-interface
parent0c8c9a89a371d6515c34d1c4f7417c26059ee969 (diff)
downloadAntennaPod-6f3a9b16764a57e43994ccbeeada5224dee93f44.zip
Create module for sync service and move DBWriter to database module (#7040)
Diffstat (limited to 'net/download/service-interface')
-rw-r--r--net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/AutoDownloadManager.java39
-rw-r--r--net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/FeedUpdateManager.java30
2 files changed, 69 insertions, 0 deletions
diff --git a/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/AutoDownloadManager.java b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/AutoDownloadManager.java
new file mode 100644
index 000000000..2eb1d1b56
--- /dev/null
+++ b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/AutoDownloadManager.java
@@ -0,0 +1,39 @@
+package de.danoeh.antennapod.net.download.serviceinterface;
+
+import android.content.Context;
+
+import java.util.concurrent.Future;
+
+public abstract class AutoDownloadManager {
+ private static AutoDownloadManager instance;
+
+ public static AutoDownloadManager getInstance() {
+ return instance;
+ }
+
+ public static void setInstance(AutoDownloadManager instance) {
+ AutoDownloadManager.instance = instance;
+ }
+
+ /**
+ * Looks for non-downloaded episodes in the queue or list of unread items and request a download if
+ * 1. Network is available
+ * 2. The device is charging or the user allows auto download on battery
+ * 3. There is free space in the episode cache
+ * This method is executed on an internal single thread executor.
+ *
+ * @param context Used for accessing the DB.
+ * @return A Future that can be used for waiting for the methods completion.
+ */
+ public abstract Future<?> autodownloadUndownloadedItems(final Context context);
+
+ /**
+ * Removed downloaded episodes outside of the queue if the episode cache is full. Episodes with a smaller
+ * 'playbackCompletionDate'-value will be deleted first.
+ * <p/>
+ * This method should NOT be executed on the GUI thread.
+ *
+ * @param context Used for accessing the DB.
+ */
+ public abstract void performAutoCleanup(final Context context);
+}
diff --git a/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/FeedUpdateManager.java b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/FeedUpdateManager.java
new file mode 100644
index 000000000..25a8f42d3
--- /dev/null
+++ b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/FeedUpdateManager.java
@@ -0,0 +1,30 @@
+package de.danoeh.antennapod.net.download.serviceinterface;
+
+import android.content.Context;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import de.danoeh.antennapod.model.feed.Feed;
+
+public abstract class FeedUpdateManager {
+ private static FeedUpdateManager instance;
+
+ public static FeedUpdateManager getInstance() {
+ return instance;
+ }
+
+ public static void setInstance(FeedUpdateManager instance) {
+ FeedUpdateManager.instance = instance;
+ }
+
+ public abstract void restartUpdateAlarm(Context context, boolean replace);
+
+ public abstract void runOnce(Context context);
+
+ public abstract void runOnce(Context context, Feed feed);
+
+ public abstract void runOnce(Context context, Feed feed, boolean nextPage);
+
+ public abstract void runOnceOrAsk(@NonNull Context context);
+
+ public abstract void runOnceOrAsk(@NonNull Context context, @Nullable Feed feed);
+}