Ignore refresh when there is no network

This commit is contained in:
ByteHamster 2021-07-11 11:12:37 +02:00
parent 81ea42a2a4
commit a0ac39e403
1 changed files with 5 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import java.util.concurrent.TimeUnit;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.FeedUpdateWorker;
import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.util.NetworkUtils;
public class AutoUpdateManager {
private static final String WORK_ID_FEED_UPDATE = "de.danoeh.antennapod.core.service.FeedUpdateWorker";
@ -118,6 +119,10 @@ public class AutoUpdateManager {
*/
public static void runImmediate(@NonNull Context context) {
Log.d(TAG, "Run auto update immediately in background.");
if (!NetworkUtils.networkAvailable()) {
Log.d(TAG, "Ignoring: No network connection.");
return;
}
new Thread(() -> DBTasks.refreshAllFeeds(
context.getApplicationContext(), true), "ManualRefreshAllFeeds").start();
}