diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2018-09-30 21:11:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-30 21:11:04 +0200 |
commit | a79c7c0cfc40eaa508344a7c0ebab8697e8c4791 (patch) | |
tree | c61a14a5945cf5da8e81f387f2c7de21515e57f7 /core/src/main/java/de | |
parent | c5245f50810fc9b957dc2986553687f6e964168d (diff) | |
parent | 7269e3cb68239957b982d5ea4c3eec9c0d97b561 (diff) | |
download | AntennaPod-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.java | 20 |
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"); } } + } |