summaryrefslogtreecommitdiff
path: root/core/src/main/java/de
diff options
context:
space:
mode:
authorMartin Fietz <Martin.Fietz@gmail.com>2018-09-30 21:11:04 +0200
committerGitHub <noreply@github.com>2018-09-30 21:11:04 +0200
commita79c7c0cfc40eaa508344a7c0ebab8697e8c4791 (patch)
treec61a14a5945cf5da8e81f387f2c7de21515e57f7 /core/src/main/java/de
parentc5245f50810fc9b957dc2986553687f6e964168d (diff)
parent7269e3cb68239957b982d5ea4c3eec9c0d97b561 (diff)
downloadAntennaPod-a79c7c0cfc40eaa508344a7c0ebab8697e8c4791.zip
Merge pull request #2839 from AntennaPod/bugfix/2691-auto-update-network-not-ready
When auto refreshing feeds, give network some time to get available
Diffstat (limited to 'core/src/main/java/de')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/FeedUpdateUtils.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/FeedUpdateUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/FeedUpdateUtils.java
index 24e0da9ed..afaf13390 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/FeedUpdateUtils.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/FeedUpdateUtils.java
@@ -2,20 +2,30 @@ package de.danoeh.antennapod.core.util;
import android.content.Context;
import android.util.Log;
+
+import org.awaitility.core.ConditionTimeoutException;
+
+import java.util.concurrent.TimeUnit;
+
import de.danoeh.antennapod.core.storage.DBTasks;
+import static org.awaitility.Awaitility.with;
+
public class FeedUpdateUtils {
private static final String TAG = "FeedUpdateUtils";
- private FeedUpdateUtils() {
-
- }
+ private FeedUpdateUtils() {}
public static void startAutoUpdate(Context context, Runnable callback) {
- if (NetworkUtils.networkAvailable() && NetworkUtils.isDownloadAllowed()) {
+ try {
+ with().pollInterval(1, TimeUnit.SECONDS)
+ .await()
+ .atMost(10, TimeUnit.SECONDS)
+ .until(() -> NetworkUtils.networkAvailable() && NetworkUtils.isDownloadAllowed());
DBTasks.refreshAllFeeds(context, null, callback);
- } else {
+ } catch (ConditionTimeoutException ignore) {
Log.d(TAG, "Blocking automatic update: no wifi available / no mobile updates allowed");
}
}
+
}