Clean up duplicate widget updates
This commit is contained in:
parent
8775031b20
commit
9dc83aa2ac
|
@ -3,14 +3,12 @@ package de.danoeh.antennapod.core.receiver;
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
import android.appwidget.AppWidgetProvider;
|
import android.appwidget.AppWidgetProvider;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import de.danoeh.antennapod.core.widget.WidgetUpdaterWorker;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.widget.WidgetUpdaterWorker;
|
|
||||||
|
|
||||||
public class PlayerWidget extends AppWidgetProvider {
|
public class PlayerWidget extends AppWidgetProvider {
|
||||||
private static final String TAG = "PlayerWidget";
|
private static final String TAG = "PlayerWidget";
|
||||||
public static final String PREFS_NAME = "PlayerWidgetPrefs";
|
public static final String PREFS_NAME = "PlayerWidgetPrefs";
|
||||||
|
@ -21,13 +19,6 @@ public class PlayerWidget extends AppWidgetProvider {
|
||||||
public static final String KEY_WIDGET_REWIND = "widget_rewind";
|
public static final String KEY_WIDGET_REWIND = "widget_rewind";
|
||||||
public static final int DEFAULT_COLOR = 0x00262C31;
|
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
|
@Override
|
||||||
public void onEnabled(Context context) {
|
public void onEnabled(Context context) {
|
||||||
super.onEnabled(context);
|
super.onEnabled(context);
|
||||||
|
|
|
@ -2,14 +2,12 @@ package de.danoeh.antennapod.core.widget;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.work.ExistingWorkPolicy;
|
||||||
import androidx.work.OneTimeWorkRequest;
|
import androidx.work.OneTimeWorkRequest;
|
||||||
import androidx.work.WorkManager;
|
import androidx.work.WorkManager;
|
||||||
import androidx.work.WorkRequest;
|
|
||||||
import androidx.work.Worker;
|
import androidx.work.Worker;
|
||||||
import androidx.work.WorkerParameters;
|
import androidx.work.WorkerParameters;
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils;
|
import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils;
|
||||||
import de.danoeh.antennapod.core.util.playback.PlayableUtils;
|
import de.danoeh.antennapod.core.util.playback.PlayableUtils;
|
||||||
import de.danoeh.antennapod.model.playback.Playable;
|
import de.danoeh.antennapod.model.playback.Playable;
|
||||||
|
@ -25,8 +23,8 @@ public class WidgetUpdaterWorker extends Worker {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void enqueueWork(final Context context) {
|
public static void enqueueWork(final Context context) {
|
||||||
final WorkRequest workRequest = new OneTimeWorkRequest.Builder(WidgetUpdaterWorker.class).build();
|
final OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(WidgetUpdaterWorker.class).build();
|
||||||
WorkManager.getInstance(context).enqueue(workRequest);
|
WorkManager.getInstance(context).enqueueUniqueWork(TAG, ExistingWorkPolicy.REPLACE, workRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
Loading…
Reference in New Issue