Merge pull request #1054 from TomHennen/fix1053

Fixes pictures disappearing in some cases
This commit is contained in:
Tom Hennen 2015-08-02 21:11:19 -04:00
commit 1dd5fcdc3b
3 changed files with 15 additions and 5 deletions

View File

@ -210,7 +210,7 @@
android:title="@string/pref_image_cache_size_title" android:title="@string/pref_image_cache_size_title"
android:key="prefImageCacheSize" android:key="prefImageCacheSize"
android:summary="@string/pref_image_cache_size_sum" android:summary="@string/pref_image_cache_size_sum"
android:defaultValue="0"/> android:defaultValue="100"/>
<Preference <Preference
android:key="prefOpmlExport" android:key="prefOpmlExport"
android:title="@string/opml_export_label"/> android:title="@string/opml_export_label"/>

View File

@ -19,6 +19,7 @@ import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
import de.danoeh.antennapod.core.service.download.HttpDownloader; import de.danoeh.antennapod.core.service.download.HttpDownloader;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.core.util.NetworkUtils;
@ -42,7 +43,7 @@ public class ApOkHttpUrlLoader implements ModelLoader<GlideUrl, InputStream> {
if (internalClient == null) { if (internalClient == null) {
synchronized (Factory.class) { synchronized (Factory.class) {
if (internalClient == null) { if (internalClient == null) {
internalClient = new OkHttpClient(); internalClient = AntennapodHttpClient.getHttpClient();
internalClient.interceptors().add(new NetworkAllowanceInterceptor()); internalClient.interceptors().add(new NetworkAllowanceInterceptor());
internalClient.interceptors().add(new BasicAuthenticationInterceptor()); internalClient.interceptors().add(new BasicAuthenticationInterceptor());
} }

View File

@ -85,6 +85,8 @@ public class UserPreferences {
private static final String PREF_FAST_FORWARD_SECS = "prefFastForwardSecs"; private static final String PREF_FAST_FORWARD_SECS = "prefFastForwardSecs";
private static final String PREF_REWIND_SECS = "prefRewindSecs"; private static final String PREF_REWIND_SECS = "prefRewindSecs";
public static final String PREF_QUEUE_LOCKED = "prefQueueLocked"; public static final String PREF_QUEUE_LOCKED = "prefQueueLocked";
public static final String IMAGE_CACHE_DEFAULT_VALUE = "100";
public static final int IMAGE_CACHE_SIZE_MINIMUM = 20;
// Constants // Constants
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1; private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
@ -279,9 +281,16 @@ public class UserPreferences {
} }
public static int getImageCacheSize() { public static int getImageCacheSize() {
String cacheSizeString = prefs.getString(PREF_IMAGE_CACHE_SIZE, "100"); String cacheSizeString = prefs.getString(PREF_IMAGE_CACHE_SIZE, IMAGE_CACHE_DEFAULT_VALUE);
int cacheSize = Integer.valueOf(cacheSizeString) * 1024 * 1024; int cacheSizeInt = Integer.valueOf(cacheSizeString);
return cacheSize; // if the cache size is too small the user won't get any images at all
// that's bad, force it back to the default.
if (cacheSizeInt < IMAGE_CACHE_SIZE_MINIMUM) {
prefs.edit().putString(PREF_IMAGE_CACHE_SIZE, IMAGE_CACHE_DEFAULT_VALUE).apply();
cacheSizeInt = Integer.valueOf(IMAGE_CACHE_DEFAULT_VALUE);
}
int cacheSizeMB = cacheSizeInt * 1024 * 1024;
return cacheSizeMB;
} }
public static int getFastFowardSecs() { public static int getFastFowardSecs() {