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";
|
String url = "https://itunes.apple.com/%s/rss/toppodcasts/limit=" + limit + "/explicit=true/json";
|
||||||
Log.d(TAG, "Feed URL " + String.format(url, country));
|
Log.d(TAG, "Feed URL " + String.format(url, country));
|
||||||
Request.Builder httpReq = new Request.Builder()
|
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));
|
.url(String.format(url, country));
|
||||||
|
|
||||||
try (Response response = client.newCall(httpReq.build()).execute()) {
|
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.exception.RxJavaErrorHandlerSetup;
|
||||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
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.
|
* 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.
|
* Apps using the core module of AntennaPod should register implementations of all interfaces here.
|
||||||
@ -44,7 +46,7 @@ public class ClientConfig {
|
|||||||
UserPreferences.init(context);
|
UserPreferences.init(context);
|
||||||
PlaybackPreferences.init(context);
|
PlaybackPreferences.init(context);
|
||||||
NetworkUtils.init(context);
|
NetworkUtils.init(context);
|
||||||
AntennapodHttpClient.setCacheDirectory(context.getCacheDir());
|
AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp"));
|
||||||
SleepTimerPreferences.init(context);
|
SleepTimerPreferences.init(context);
|
||||||
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
||||||
NotificationUtils.createChannels(context);
|
NotificationUtils.createChannels(context);
|
||||||
|
@ -1,41 +1,31 @@
|
|||||||
package de.danoeh.antennapod.core.glide;
|
package de.danoeh.antennapod.core.glide;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher;
|
import com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher;
|
||||||
import com.bumptech.glide.load.Options;
|
import com.bumptech.glide.load.Options;
|
||||||
import com.bumptech.glide.load.model.GlideUrl;
|
import com.bumptech.glide.load.model.GlideUrl;
|
||||||
import com.bumptech.glide.load.model.ModelLoader;
|
import com.bumptech.glide.load.model.ModelLoader;
|
||||||
import com.bumptech.glide.load.model.ModelLoaderFactory;
|
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.load.model.MultiModelLoaderFactory;
|
||||||
import com.bumptech.glide.signature.ObjectKey;
|
import com.bumptech.glide.signature.ObjectKey;
|
||||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
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 de.danoeh.antennapod.core.util.NetworkUtils;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Protocol;
|
import okhttp3.Protocol;
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
|
* @see com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
|
||||||
*/
|
*/
|
||||||
class ApOkHttpUrlLoader implements ModelLoader<String, InputStream> {
|
class ApOkHttpUrlLoader implements ModelLoader<String, InputStream> {
|
||||||
|
|
||||||
private static final String TAG = ApOkHttpUrlLoader.class.getSimpleName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default factory for {@link ApOkHttpUrlLoader}s.
|
* The default factory for {@link ApOkHttpUrlLoader}s.
|
||||||
*/
|
*/
|
||||||
@ -50,6 +40,7 @@ class ApOkHttpUrlLoader implements ModelLoader<String, InputStream> {
|
|||||||
if (internalClient == null) {
|
if (internalClient == null) {
|
||||||
OkHttpClient.Builder builder = AntennapodHttpClient.newBuilder();
|
OkHttpClient.Builder builder = AntennapodHttpClient.newBuilder();
|
||||||
builder.interceptors().add(new NetworkAllowanceInterceptor());
|
builder.interceptors().add(new NetworkAllowanceInterceptor());
|
||||||
|
builder.cache(null); // Handled by Glide
|
||||||
internalClient = builder.build();
|
internalClient = builder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,8 +100,9 @@ class ApOkHttpUrlLoader implements ModelLoader<String, InputStream> {
|
|||||||
|
|
||||||
private static class NetworkAllowanceInterceptor implements Interceptor {
|
private static class NetworkAllowanceInterceptor implements Interceptor {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Response intercept(Chain chain) throws IOException {
|
public Response intercept(@NonNull Chain chain) throws IOException {
|
||||||
if (NetworkUtils.isImageAllowed()) {
|
if (NetworkUtils.isImageAllowed()) {
|
||||||
return chain.proceed(chain.request());
|
return chain.proceed(chain.request());
|
||||||
} else {
|
} 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.exception.RxJavaErrorHandlerSetup;
|
||||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
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.
|
* 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.
|
* 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.");
|
Log.v(TAG, "Cast is disabled. All Cast-related initialization will be skipped.");
|
||||||
}
|
}
|
||||||
installSslProvider(context);
|
installSslProvider(context);
|
||||||
AntennapodHttpClient.setCacheDirectory(context.getCacheDir());
|
AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp"));
|
||||||
SleepTimerPreferences.init(context);
|
SleepTimerPreferences.init(context);
|
||||||
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
||||||
NotificationUtils.createChannels(context);
|
NotificationUtils.createChannels(context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user