Use settings from preferences for readTimeout

This commit is contained in:
Simão Mata 2020-04-30 16:25:11 +02:00
parent ec083cd79d
commit 3c17e91ca8
2 changed files with 9 additions and 1 deletions

View File

@ -592,7 +592,7 @@ public class RESTMusicService implements MusicService {
public Response getDownloadInputStream(Context context, MusicDirectory.Entry song, long offset, int maxBitrate, SilentBackgroundTask task) throws Exception {
OkHttpClient eagerClient = client.newBuilder()
.readTimeout(30, TimeUnit.SECONDS)
.readTimeout(Util.getNetworkTimeoutMs(context), TimeUnit.MILLISECONDS)
.build();
Map<String, String> parameters = new HashMap<>();

View File

@ -72,6 +72,9 @@ import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -122,6 +125,11 @@ public final class Util {
editor.apply();
}
public static int getNetworkTimeoutMs(Context context) {
SharedPreferences prefs = getPreferences(context);
return prefs.getInt(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT, 30000);
}
public static boolean isScreenLitOnDownload(Context context) {
SharedPreferences prefs = getPreferences(context);
return prefs.getBoolean(Constants.PREFERENCES_KEY_SCREEN_LIT_ON_DOWNLOAD, false);