Merge pull request #5264 from ByteHamster/ignore-refresh-no-network
Ignore refresh when there is no network
This commit is contained in:
commit
f43cd69ada
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue