Do not cache images, accept old iTunes responses
This commit is contained in:
parent
bb13b1e5f3
commit
9ff4687821
|
@ -82,7 +82,7 @@ public class ItunesTopListLoader {
|
|||
String url = "https://itunes.apple.com/%s/rss/toppodcasts/limit=" + limit + "/explicit=true/json";
|
||||
Log.d(TAG, "Feed URL " + String.format(url, country));
|
||||
Request.Builder httpReq = new Request.Builder()
|
||||
.cacheControl(new CacheControl.Builder().minFresh(1, TimeUnit.DAYS).build())
|
||||
.cacheControl(new CacheControl.Builder().maxStale(1, TimeUnit.DAYS).build())
|
||||
.url(String.format(url, country));
|
||||
|
||||
try (Response response = client.newCall(httpReq.build()).execute()) {
|
||||
|
|
|
@ -11,6 +11,8 @@ import de.danoeh.antennapod.core.util.NetworkUtils;
|
|||
import de.danoeh.antennapod.core.util.exception.RxJavaErrorHandlerSetup;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Stores callbacks for core classes like Services, DB classes etc. and other configuration variables.
|
||||
* Apps using the core module of AntennaPod should register implementations of all interfaces here.
|
||||
|
@ -44,7 +46,7 @@ public class ClientConfig {
|
|||
UserPreferences.init(context);
|
||||
PlaybackPreferences.init(context);
|
||||
NetworkUtils.init(context);
|
||||
AntennapodHttpClient.setCacheDirectory(context.getCacheDir());
|
||||
AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp"));
|
||||
SleepTimerPreferences.init(context);
|
||||
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
||||
NotificationUtils.createChannels(context);
|
||||
|
|
|
@ -1,41 +1,31 @@
|
|||
package de.danoeh.antennapod.core.glide;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher;
|
||||
import com.bumptech.glide.load.Options;
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
import com.bumptech.glide.load.model.ModelLoader;
|
||||
import com.bumptech.glide.load.model.ModelLoaderFactory;
|
||||
|
||||
import de.danoeh.antennapod.core.service.BasicAuthorizationInterceptor;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
|
||||
import com.bumptech.glide.load.model.MultiModelLoaderFactory;
|
||||
import com.bumptech.glide.signature.ObjectKey;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.service.download.HttpDownloader;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @see com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
|
||||
*/
|
||||
class ApOkHttpUrlLoader implements ModelLoader<String, InputStream> {
|
||||
|
||||
private static final String TAG = ApOkHttpUrlLoader.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* The default factory for {@link ApOkHttpUrlLoader}s.
|
||||
*/
|
||||
|
@ -50,6 +40,7 @@ class ApOkHttpUrlLoader implements ModelLoader<String, InputStream> {
|
|||
if (internalClient == null) {
|
||||
OkHttpClient.Builder builder = AntennapodHttpClient.newBuilder();
|
||||
builder.interceptors().add(new NetworkAllowanceInterceptor());
|
||||
builder.cache(null); // Handled by Glide
|
||||
internalClient = builder.build();
|
||||
}
|
||||
}
|
||||
|
@ -109,8 +100,9 @@ class ApOkHttpUrlLoader implements ModelLoader<String, InputStream> {
|
|||
|
||||
private static class NetworkAllowanceInterceptor implements Interceptor {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
if (NetworkUtils.isImageAllowed()) {
|
||||
return chain.proceed(chain.request());
|
||||
} else {
|
||||
|
|
|
@ -17,6 +17,8 @@ import de.danoeh.antennapod.core.util.NetworkUtils;
|
|||
import de.danoeh.antennapod.core.util.exception.RxJavaErrorHandlerSetup;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Stores callbacks for core classes like Services, DB classes etc. and other configuration variables.
|
||||
* Apps using the core module of AntennaPod should register implementations of all interfaces here.
|
||||
|
@ -63,7 +65,7 @@ public class ClientConfig {
|
|||
Log.v(TAG, "Cast is disabled. All Cast-related initialization will be skipped.");
|
||||
}
|
||||
installSslProvider(context);
|
||||
AntennapodHttpClient.setCacheDirectory(context.getCacheDir());
|
||||
AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp"));
|
||||
SleepTimerPreferences.init(context);
|
||||
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
||||
NotificationUtils.createChannels(context);
|
||||
|
|
Loading…
Reference in New Issue