mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-22 22:28:10 +01:00
Merge pull request #2839 from AntennaPod/bugfix/2691-auto-update-network-not-ready
When auto refreshing feeds, give network some time to get available
This commit is contained in:
commit
a79c7c0cfc
@ -43,6 +43,7 @@ project.ext {
|
||||
targetSdkVersion = 26
|
||||
|
||||
supportVersion = "26.1.0"
|
||||
awaitilityVersion = "3.1.2"
|
||||
commonsioVersion = "2.5"
|
||||
commonslangVersion = "3.6"
|
||||
commonstextVersion = "1.3"
|
||||
|
@ -66,6 +66,7 @@ dependencies {
|
||||
implementation "com.squareup.okio:okio:$okioVersion"
|
||||
implementation "de.greenrobot:eventbus:$eventbusVersion"
|
||||
implementation "io.reactivex:rxandroid:$rxAndroidVersion"
|
||||
implementation "org.awaitility:awaitility:$awaitilityVersion"
|
||||
|
||||
implementation "com.google.android.exoplayer:exoplayer:$exoPlayerVersion"
|
||||
implementation "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion"
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user