mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-10-29 19:59:22 +00:00
Add message: Please wait some time before refreshing again (#7950)
This commit is contained in:
parent
3a94f1f430
commit
5eccb2e64e
@ -34,6 +34,8 @@ public class FeedUpdateManagerImpl extends FeedUpdateManager {
|
|||||||
public static final String EXTRA_EVEN_ON_MOBILE = "even_on_mobile";
|
public static final String EXTRA_EVEN_ON_MOBILE = "even_on_mobile";
|
||||||
public static final String EXTRA_MANUAL = "manual";
|
public static final String EXTRA_MANUAL = "manual";
|
||||||
private static final String TAG = "AutoUpdateManager";
|
private static final String TAG = "AutoUpdateManager";
|
||||||
|
private static long lastManualRefreshTime = 0;
|
||||||
|
private static final long REFRESH_COOLDOWN_MS = 20_000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start / restart periodic auto feed refresh
|
* Start / restart periodic auto feed refresh
|
||||||
@ -64,6 +66,7 @@ public class FeedUpdateManagerImpl extends FeedUpdateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runOnce(Context context, Feed feed, boolean nextPage) {
|
public void runOnce(Context context, Feed feed, boolean nextPage) {
|
||||||
|
lastManualRefreshTime = System.currentTimeMillis();
|
||||||
OneTimeWorkRequest.Builder workRequest = new OneTimeWorkRequest.Builder(FeedUpdateWorker.class)
|
OneTimeWorkRequest.Builder workRequest = new OneTimeWorkRequest.Builder(FeedUpdateWorker.class)
|
||||||
.setInitialDelay(0L, TimeUnit.MILLISECONDS)
|
.setInitialDelay(0L, TimeUnit.MILLISECONDS)
|
||||||
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
|
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
|
||||||
@ -89,6 +92,11 @@ public class FeedUpdateManagerImpl extends FeedUpdateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runOnceOrAsk(@NonNull Context context, @Nullable Feed feed) {
|
public void runOnceOrAsk(@NonNull Context context, @Nullable Feed feed) {
|
||||||
|
if (System.currentTimeMillis() - lastManualRefreshTime < REFRESH_COOLDOWN_MS) {
|
||||||
|
EventBus.getDefault().post(new MessageEvent(context.getString(R.string.please_wait_before_refreshing)));
|
||||||
|
EventBus.getDefault().postSticky(new FeedUpdateRunningEvent(false));
|
||||||
|
return;
|
||||||
|
}
|
||||||
Log.d(TAG, "Run auto update immediately in background.");
|
Log.d(TAG, "Run auto update immediately in background.");
|
||||||
if (feed != null && feed.isLocalFeed()) {
|
if (feed != null && feed.isLocalFeed()) {
|
||||||
runOnce(context, feed);
|
runOnce(context, feed);
|
||||||
|
|||||||
@ -211,6 +211,7 @@
|
|||||||
<string name="multi_select_started_talkback">Multi select actions shown at the bottom</string>
|
<string name="multi_select_started_talkback">Multi select actions shown at the bottom</string>
|
||||||
<string name="filtered_label">Filtered</string>
|
<string name="filtered_label">Filtered</string>
|
||||||
<string name="refresh_failed_msg">Last refresh failed. Tap to view details.</string>
|
<string name="refresh_failed_msg">Last refresh failed. Tap to view details.</string>
|
||||||
|
<string name="please_wait_before_refreshing">Please wait some time before refreshing podcasts again.</string>
|
||||||
<string name="open_podcast">Open podcast</string>
|
<string name="open_podcast">Open podcast</string>
|
||||||
<string name="please_wait_for_data">Please wait until the data is loaded</string>
|
<string name="please_wait_for_data">Please wait until the data is loaded</string>
|
||||||
<string name="updates_disabled_label">Updates disabled</string>
|
<string name="updates_disabled_label">Updates disabled</string>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user