summaryrefslogtreecommitdiff
path: root/event
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2021-11-02 20:58:05 +0100
committerByteHamster <info@bytehamster.com>2021-11-02 21:02:47 +0100
commit98830beee54bc6fb1e0763481cd18f549c6d6ec7 (patch)
treeb17d526a3fe5d54c1dfd39c922979396efd5f567 /event
parent61a140a51019bb8f987c27a21a8d7be4422a4e72 (diff)
downloadAntennaPod-98830beee54bc6fb1e0763481cd18f549c6d6ec7.zip
Move (most) events to their own module
Diffstat (limited to 'event')
-rw-r--r--event/build.gradle8
-rw-r--r--event/src/main/AndroidManifest.xml1
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/DiscoveryDefaultUpdateEvent.java6
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/FavoritesEvent.java26
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java41
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/FeedListUpdateEvent.java28
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/MessageEvent.java21
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/PlayerErrorEvent.java13
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/PlayerStatusEvent.java6
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/QueueEvent.java58
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/SyncServiceEvent.java13
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/UnreadItemsUpdateEvent.java6
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/playback/BufferUpdateEvent.java35
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackHistoryEvent.java16
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackPositionEvent.java19
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackServiceEvent.java14
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/playback/SleepTimerUpdatedEvent.java38
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/playback/SpeedChangedEvent.java13
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/settings/SkipIntroEndingChangedEvent.java25
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/settings/SpeedPresetChangedEvent.java19
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/settings/VolumeAdaptionChangedEvent.java21
21 files changed, 427 insertions, 0 deletions
diff --git a/event/build.gradle b/event/build.gradle
new file mode 100644
index 000000000..c852c0351
--- /dev/null
+++ b/event/build.gradle
@@ -0,0 +1,8 @@
+apply plugin: "com.android.library"
+apply from: "../common.gradle"
+
+dependencies {
+ implementation project(':model')
+
+ annotationProcessor "androidx.annotation:annotation:$annotationVersion"
+}
diff --git a/event/src/main/AndroidManifest.xml b/event/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..7561cf555
--- /dev/null
+++ b/event/src/main/AndroidManifest.xml
@@ -0,0 +1 @@
+<manifest package="de.danoeh.antennapod.event" />
diff --git a/event/src/main/java/de/danoeh/antennapod/event/DiscoveryDefaultUpdateEvent.java b/event/src/main/java/de/danoeh/antennapod/event/DiscoveryDefaultUpdateEvent.java
new file mode 100644
index 000000000..944c7759a
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/DiscoveryDefaultUpdateEvent.java
@@ -0,0 +1,6 @@
+package de.danoeh.antennapod.event;
+
+public class DiscoveryDefaultUpdateEvent {
+ public DiscoveryDefaultUpdateEvent() {
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/FavoritesEvent.java b/event/src/main/java/de/danoeh/antennapod/event/FavoritesEvent.java
new file mode 100644
index 000000000..8b27f74ab
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/FavoritesEvent.java
@@ -0,0 +1,26 @@
+package de.danoeh.antennapod.event;
+
+import de.danoeh.antennapod.model.feed.FeedItem;
+
+public class FavoritesEvent {
+
+ public enum Action {
+ ADDED, REMOVED
+ }
+
+ private final Action action;
+ private final FeedItem item;
+
+ private FavoritesEvent(Action action, FeedItem item) {
+ this.action = action;
+ this.item = item;
+ }
+
+ public static FavoritesEvent added(FeedItem item) {
+ return new FavoritesEvent(Action.ADDED, item);
+ }
+
+ public static FavoritesEvent removed(FeedItem item) {
+ return new FavoritesEvent(Action.REMOVED, item);
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java b/event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java
new file mode 100644
index 000000000..6c7adc2d7
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java
@@ -0,0 +1,41 @@
+package de.danoeh.antennapod.event;
+
+
+import androidx.annotation.NonNull;
+
+import java.util.Arrays;
+import java.util.List;
+
+import de.danoeh.antennapod.model.feed.FeedItem;
+
+public class FeedItemEvent {
+
+ public enum Action {
+ UPDATE, DELETE_MEDIA
+ }
+
+ @NonNull
+ private final Action action;
+ @NonNull public final List<FeedItem> items;
+
+ private FeedItemEvent(@NonNull Action action, @NonNull List<FeedItem> items) {
+ this.action = action;
+ this.items = items;
+ }
+
+ public static FeedItemEvent deletedMedia(List<FeedItem> items) {
+ return new FeedItemEvent(Action.DELETE_MEDIA, items);
+ }
+
+ public static FeedItemEvent deletedMedia(FeedItem... items) {
+ return deletedMedia(Arrays.asList(items));
+ }
+
+ public static FeedItemEvent updated(List<FeedItem> items) {
+ return new FeedItemEvent(Action.UPDATE, items);
+ }
+
+ public static FeedItemEvent updated(FeedItem... items) {
+ return updated(Arrays.asList(items));
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/FeedListUpdateEvent.java b/event/src/main/java/de/danoeh/antennapod/event/FeedListUpdateEvent.java
new file mode 100644
index 000000000..99a83abec
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/FeedListUpdateEvent.java
@@ -0,0 +1,28 @@
+package de.danoeh.antennapod.event;
+
+import de.danoeh.antennapod.model.feed.Feed;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class FeedListUpdateEvent {
+ private final List<Long> feeds = new ArrayList<>();
+
+ public FeedListUpdateEvent(List<Feed> feeds) {
+ for (Feed feed : feeds) {
+ this.feeds.add(feed.getId());
+ }
+ }
+
+ public FeedListUpdateEvent(Feed feed) {
+ feeds.add(feed.getId());
+ }
+
+ public FeedListUpdateEvent(long feedId) {
+ feeds.add(feedId);
+ }
+
+ public boolean contains(Feed feed) {
+ return feeds.contains(feed.getId());
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/MessageEvent.java b/event/src/main/java/de/danoeh/antennapod/event/MessageEvent.java
new file mode 100644
index 000000000..3f6b2db32
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/MessageEvent.java
@@ -0,0 +1,21 @@
+package de.danoeh.antennapod.event;
+
+import androidx.annotation.Nullable;
+
+public class MessageEvent {
+
+ public final String message;
+
+ @Nullable
+ public final Runnable action;
+
+ public MessageEvent(String message) {
+ this(message, null);
+ }
+
+ public MessageEvent(String message, Runnable action) {
+ this.message = message;
+ this.action = action;
+ }
+
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/PlayerErrorEvent.java b/event/src/main/java/de/danoeh/antennapod/event/PlayerErrorEvent.java
new file mode 100644
index 000000000..662a16f81
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/PlayerErrorEvent.java
@@ -0,0 +1,13 @@
+package de.danoeh.antennapod.event;
+
+public class PlayerErrorEvent {
+ private final String message;
+
+ public PlayerErrorEvent(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/PlayerStatusEvent.java b/event/src/main/java/de/danoeh/antennapod/event/PlayerStatusEvent.java
new file mode 100644
index 000000000..4074bd98f
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/PlayerStatusEvent.java
@@ -0,0 +1,6 @@
+package de.danoeh.antennapod.event;
+
+public class PlayerStatusEvent {
+ public PlayerStatusEvent() {
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/QueueEvent.java b/event/src/main/java/de/danoeh/antennapod/event/QueueEvent.java
new file mode 100644
index 000000000..578398865
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/QueueEvent.java
@@ -0,0 +1,58 @@
+package de.danoeh.antennapod.event;
+
+import androidx.annotation.Nullable;
+
+import java.util.List;
+
+import de.danoeh.antennapod.model.feed.FeedItem;
+
+public class QueueEvent {
+
+ public enum Action {
+ ADDED, ADDED_ITEMS, SET_QUEUE, REMOVED, IRREVERSIBLE_REMOVED, CLEARED, DELETED_MEDIA, SORTED, MOVED
+ }
+
+ public final Action action;
+ public final FeedItem item;
+ public final int position;
+ public final List<FeedItem> items;
+
+
+ private QueueEvent(Action action,
+ @Nullable FeedItem item,
+ @Nullable List<FeedItem> items,
+ int position) {
+ this.action = action;
+ this.item = item;
+ this.items = items;
+ this.position = position;
+ }
+
+ public static QueueEvent added(FeedItem item, int position) {
+ return new QueueEvent(Action.ADDED, item, null, position);
+ }
+
+ public static QueueEvent setQueue(List<FeedItem> queue) {
+ return new QueueEvent(Action.SET_QUEUE, null, queue, -1);
+ }
+
+ public static QueueEvent removed(FeedItem item) {
+ return new QueueEvent(Action.REMOVED, item, null, -1);
+ }
+
+ public static QueueEvent irreversibleRemoved(FeedItem item) {
+ return new QueueEvent(Action.IRREVERSIBLE_REMOVED, item, null, -1);
+ }
+
+ public static QueueEvent cleared() {
+ return new QueueEvent(Action.CLEARED, null, null, -1);
+ }
+
+ public static QueueEvent sorted(List<FeedItem> sortedQueue) {
+ return new QueueEvent(Action.SORTED, null, sortedQueue, -1);
+ }
+
+ public static QueueEvent moved(FeedItem item, int newPosition) {
+ return new QueueEvent(Action.MOVED, item, null, newPosition);
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/SyncServiceEvent.java b/event/src/main/java/de/danoeh/antennapod/event/SyncServiceEvent.java
new file mode 100644
index 000000000..2ebac8c0a
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/SyncServiceEvent.java
@@ -0,0 +1,13 @@
+package de.danoeh.antennapod.event;
+
+public class SyncServiceEvent {
+ private final int messageResId;
+
+ public SyncServiceEvent(int messageResId) {
+ this.messageResId = messageResId;
+ }
+
+ public int getMessageResId() {
+ return messageResId;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/UnreadItemsUpdateEvent.java b/event/src/main/java/de/danoeh/antennapod/event/UnreadItemsUpdateEvent.java
new file mode 100644
index 000000000..fb1bbc739
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/UnreadItemsUpdateEvent.java
@@ -0,0 +1,6 @@
+package de.danoeh.antennapod.event;
+
+public class UnreadItemsUpdateEvent {
+ public UnreadItemsUpdateEvent() {
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/playback/BufferUpdateEvent.java b/event/src/main/java/de/danoeh/antennapod/event/playback/BufferUpdateEvent.java
new file mode 100644
index 000000000..57d41ad13
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/playback/BufferUpdateEvent.java
@@ -0,0 +1,35 @@
+package de.danoeh.antennapod.event.playback;
+
+public class BufferUpdateEvent {
+ private static final float PROGRESS_STARTED = -1;
+ private static final float PROGRESS_ENDED = -2;
+ final float progress;
+
+ private BufferUpdateEvent(float progress) {
+ this.progress = progress;
+ }
+
+ public static BufferUpdateEvent started() {
+ return new BufferUpdateEvent(PROGRESS_STARTED);
+ }
+
+ public static BufferUpdateEvent ended() {
+ return new BufferUpdateEvent(PROGRESS_ENDED);
+ }
+
+ public static BufferUpdateEvent progressUpdate(float progress) {
+ return new BufferUpdateEvent(progress);
+ }
+
+ public float getProgress() {
+ return progress;
+ }
+
+ public boolean hasStarted() {
+ return progress == PROGRESS_STARTED;
+ }
+
+ public boolean hasEnded() {
+ return progress == PROGRESS_ENDED;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackHistoryEvent.java b/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackHistoryEvent.java
new file mode 100644
index 000000000..b51377a3d
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackHistoryEvent.java
@@ -0,0 +1,16 @@
+package de.danoeh.antennapod.event.playback;
+
+public class PlaybackHistoryEvent {
+
+ private PlaybackHistoryEvent() {
+ }
+
+ public static PlaybackHistoryEvent listUpdated() {
+ return new PlaybackHistoryEvent();
+ }
+
+ @Override
+ public String toString() {
+ return "PlaybackHistoryEvent";
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackPositionEvent.java b/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackPositionEvent.java
new file mode 100644
index 000000000..3746680eb
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackPositionEvent.java
@@ -0,0 +1,19 @@
+package de.danoeh.antennapod.event.playback;
+
+public class PlaybackPositionEvent {
+ private final int position;
+ private final int duration;
+
+ public PlaybackPositionEvent(int position, int duration) {
+ this.position = position;
+ this.duration = duration;
+ }
+
+ public int getPosition() {
+ return position;
+ }
+
+ public int getDuration() {
+ return duration;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackServiceEvent.java b/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackServiceEvent.java
new file mode 100644
index 000000000..8115730dd
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/playback/PlaybackServiceEvent.java
@@ -0,0 +1,14 @@
+package de.danoeh.antennapod.event.playback;
+
+public class PlaybackServiceEvent {
+ public enum Action {
+ SERVICE_STARTED,
+ SERVICE_SHUT_DOWN
+ }
+
+ public final Action action;
+
+ public PlaybackServiceEvent(Action action) {
+ this.action = action;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/playback/SleepTimerUpdatedEvent.java b/event/src/main/java/de/danoeh/antennapod/event/playback/SleepTimerUpdatedEvent.java
new file mode 100644
index 000000000..be61435a0
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/playback/SleepTimerUpdatedEvent.java
@@ -0,0 +1,38 @@
+package de.danoeh.antennapod.event.playback;
+
+public class SleepTimerUpdatedEvent {
+ private static final long CANCELLED = Long.MAX_VALUE;
+ private final long timeLeft;
+
+ private SleepTimerUpdatedEvent(long timeLeft) {
+ this.timeLeft = timeLeft;
+ }
+
+ public static SleepTimerUpdatedEvent justEnabled(long timeLeft) {
+ return new SleepTimerUpdatedEvent(-timeLeft);
+ }
+
+ public static SleepTimerUpdatedEvent updated(long timeLeft) {
+ return new SleepTimerUpdatedEvent(Math.max(0, timeLeft));
+ }
+
+ public static SleepTimerUpdatedEvent cancelled() {
+ return new SleepTimerUpdatedEvent(CANCELLED);
+ }
+
+ public long getTimeLeft() {
+ return Math.abs(timeLeft);
+ }
+
+ public boolean isOver() {
+ return timeLeft == 0;
+ }
+
+ public boolean wasJustEnabled() {
+ return timeLeft < 0;
+ }
+
+ public boolean isCancelled() {
+ return timeLeft == CANCELLED;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/playback/SpeedChangedEvent.java b/event/src/main/java/de/danoeh/antennapod/event/playback/SpeedChangedEvent.java
new file mode 100644
index 000000000..243d20628
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/playback/SpeedChangedEvent.java
@@ -0,0 +1,13 @@
+package de.danoeh.antennapod.event.playback;
+
+public class SpeedChangedEvent {
+ private final float newSpeed;
+
+ public SpeedChangedEvent(float newSpeed) {
+ this.newSpeed = newSpeed;
+ }
+
+ public float getNewSpeed() {
+ return newSpeed;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/settings/SkipIntroEndingChangedEvent.java b/event/src/main/java/de/danoeh/antennapod/event/settings/SkipIntroEndingChangedEvent.java
new file mode 100644
index 000000000..bb6010796
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/settings/SkipIntroEndingChangedEvent.java
@@ -0,0 +1,25 @@
+package de.danoeh.antennapod.event.settings;
+
+public class SkipIntroEndingChangedEvent {
+ private final int skipIntro;
+ private final int skipEnding;
+ private final long feedId;
+
+ public SkipIntroEndingChangedEvent(int skipIntro, int skipEnding, long feedId) {
+ this.skipIntro= skipIntro;
+ this.skipEnding = skipEnding;
+ this.feedId = feedId;
+ }
+
+ public int getSkipIntro() {
+ return skipIntro;
+ }
+
+ public int getSkipEnding() {
+ return skipEnding;
+ }
+
+ public long getFeedId() {
+ return feedId;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/settings/SpeedPresetChangedEvent.java b/event/src/main/java/de/danoeh/antennapod/event/settings/SpeedPresetChangedEvent.java
new file mode 100644
index 000000000..6ca8a1290
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/settings/SpeedPresetChangedEvent.java
@@ -0,0 +1,19 @@
+package de.danoeh.antennapod.event.settings;
+
+public class SpeedPresetChangedEvent {
+ private final float speed;
+ private final long feedId;
+
+ public SpeedPresetChangedEvent(float speed, long feedId) {
+ this.speed = speed;
+ this.feedId = feedId;
+ }
+
+ public float getSpeed() {
+ return speed;
+ }
+
+ public long getFeedId() {
+ return feedId;
+ }
+}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/settings/VolumeAdaptionChangedEvent.java b/event/src/main/java/de/danoeh/antennapod/event/settings/VolumeAdaptionChangedEvent.java
new file mode 100644
index 000000000..5a2c0b63c
--- /dev/null
+++ b/event/src/main/java/de/danoeh/antennapod/event/settings/VolumeAdaptionChangedEvent.java
@@ -0,0 +1,21 @@
+package de.danoeh.antennapod.event.settings;
+
+import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting;
+
+public class VolumeAdaptionChangedEvent {
+ private final VolumeAdaptionSetting volumeAdaptionSetting;
+ private final long feedId;
+
+ public VolumeAdaptionChangedEvent(VolumeAdaptionSetting volumeAdaptionSetting, long feedId) {
+ this.volumeAdaptionSetting = volumeAdaptionSetting;
+ this.feedId = feedId;
+ }
+
+ public VolumeAdaptionSetting getVolumeAdaptionSetting() {
+ return volumeAdaptionSetting;
+ }
+
+ public long getFeedId() {
+ return feedId;
+ }
+}