diff options
author | ByteHamster <info@bytehamster.com> | 2022-04-24 10:43:24 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-04-24 10:43:29 +0200 |
commit | 9dc83aa2ac8a70362e68e7e2e9164879028cc213 (patch) | |
tree | 869f97ef8f2e567151b741f1ee4bc4820d819e70 | |
parent | 8775031b20cbb10876b36541f346e0a0efdad1cb (diff) | |
download | AntennaPod-9dc83aa2ac8a70362e68e7e2e9164879028cc213.zip |
Clean up duplicate widget updates
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java | 11 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdaterWorker.java | 8 |
2 files changed, 4 insertions, 15 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java index 842dcdf75..46faeec50 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java +++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java @@ -3,14 +3,12 @@ package de.danoeh.antennapod.core.receiver; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android.content.Context; -import android.content.Intent; import android.content.SharedPreferences; import android.util.Log; +import de.danoeh.antennapod.core.widget.WidgetUpdaterWorker; import java.util.Arrays; -import de.danoeh.antennapod.core.widget.WidgetUpdaterWorker; - public class PlayerWidget extends AppWidgetProvider { private static final String TAG = "PlayerWidget"; public static final String PREFS_NAME = "PlayerWidgetPrefs"; @@ -22,13 +20,6 @@ public class PlayerWidget extends AppWidgetProvider { public static final int DEFAULT_COLOR = 0x00262C31; @Override - public void onReceive(Context context, Intent intent) { - Log.d(TAG, "onReceive"); - super.onReceive(context, intent); - WidgetUpdaterWorker.enqueueWork(context); - } - - @Override public void onEnabled(Context context) { super.onEnabled(context); Log.d(TAG, "Widget enabled"); diff --git a/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdaterWorker.java b/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdaterWorker.java index 3b8546a8e..5bf924ad9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdaterWorker.java +++ b/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdaterWorker.java @@ -2,14 +2,12 @@ package de.danoeh.antennapod.core.widget; import android.content.Context; import android.util.Log; - import androidx.annotation.NonNull; +import androidx.work.ExistingWorkPolicy; import androidx.work.OneTimeWorkRequest; import androidx.work.WorkManager; -import androidx.work.WorkRequest; import androidx.work.Worker; import androidx.work.WorkerParameters; - import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils; import de.danoeh.antennapod.core.util.playback.PlayableUtils; import de.danoeh.antennapod.model.playback.Playable; @@ -25,8 +23,8 @@ public class WidgetUpdaterWorker extends Worker { } public static void enqueueWork(final Context context) { - final WorkRequest workRequest = new OneTimeWorkRequest.Builder(WidgetUpdaterWorker.class).build(); - WorkManager.getInstance(context).enqueue(workRequest); + final OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(WidgetUpdaterWorker.class).build(); + WorkManager.getInstance(context).enqueueUniqueWork(TAG, ExistingWorkPolicy.REPLACE, workRequest); } @NonNull |