Merge pull request #5264 from ByteHamster/ignore-refresh-no-network

Ignore refresh when there is no network
This commit is contained in:
ByteHamster 2021-07-11 11:37:05 +02:00 committed by GitHub
commit f43cd69ada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.FeedUpdateWorker; import de.danoeh.antennapod.core.service.FeedUpdateWorker;
import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.util.NetworkUtils;
public class AutoUpdateManager { public class AutoUpdateManager {
private static final String WORK_ID_FEED_UPDATE = "de.danoeh.antennapod.core.service.FeedUpdateWorker"; 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) { public static void runImmediate(@NonNull Context context) {
Log.d(TAG, "Run auto update immediately in background."); Log.d(TAG, "Run auto update immediately in background.");
if (!NetworkUtils.networkAvailable()) {
Log.d(TAG, "Ignoring: No network connection.");
return;
}
new Thread(() -> DBTasks.refreshAllFeeds( new Thread(() -> DBTasks.refreshAllFeeds(
context.getApplicationContext(), true), "ManualRefreshAllFeeds").start(); context.getApplicationContext(), true), "ManualRefreshAllFeeds").start();
} }