diff options
-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 |