mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-04 16:53:55 +01:00
5120: Put back unwanted changes
This commit is contained in:
parent
cc115f1e76
commit
f96a5edbb9
1 changed files with 16 additions and 21 deletions
|
|
@ -19,19 +19,15 @@ import org.wikipedia.dataclient.okhttp.HttpStatusException;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public final class OkHttpConnectionFactory {
|
public final class OkHttpConnectionFactory {
|
||||||
|
|
||||||
private static final String CACHE_DIR_NAME = "okhttp-cache";
|
private static final String CACHE_DIR_NAME = "okhttp-cache";
|
||||||
private static final long NET_CACHE_SIZE = 64 * 1024 * 1024;
|
private static final long NET_CACHE_SIZE = 64 * 1024 * 1024;
|
||||||
@NonNull
|
@NonNull private static final Cache NET_CACHE = new Cache(new File(CommonsApplication.getInstance().getCacheDir(),
|
||||||
private static final Cache NET_CACHE = new Cache(
|
|
||||||
new File(CommonsApplication.getInstance().getCacheDir(),
|
|
||||||
CACHE_DIR_NAME), NET_CACHE_SIZE);
|
CACHE_DIR_NAME), NET_CACHE_SIZE);
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private static final OkHttpClient CLIENT = createClient();
|
private static final OkHttpClient CLIENT = createClient();
|
||||||
|
|
||||||
@NonNull
|
@NonNull public static OkHttpClient getClient() {
|
||||||
public static OkHttpClient getClient() {
|
|
||||||
return CLIENT;
|
return CLIENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,7 +68,6 @@ public final class OkHttpConnectionFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UnsuccessfulResponseInterceptor implements Interceptor {
|
public static class UnsuccessfulResponseInterceptor implements Interceptor {
|
||||||
|
|
||||||
private static final List<String> DO_NOT_INTERCEPT = Collections.singletonList(
|
private static final List<String> DO_NOT_INTERCEPT = Collections.singletonList(
|
||||||
"api.php?format=json&formatversion=2&errorformat=plaintext&action=upload&ignorewarnings=1");
|
"api.php?format=json&formatversion=2&errorformat=plaintext&action=upload&ignorewarnings=1");
|
||||||
|
|
||||||
|
|
@ -84,7 +79,7 @@ public final class OkHttpConnectionFactory {
|
||||||
final Response rsp = chain.proceed(chain.request());
|
final Response rsp = chain.proceed(chain.request());
|
||||||
|
|
||||||
// Do not intercept certain requests and let the caller handle the errors
|
// Do not intercept certain requests and let the caller handle the errors
|
||||||
if (isExcludedUrl(chain.request())) {
|
if(isExcludedUrl(chain.request())) {
|
||||||
return rsp;
|
return rsp;
|
||||||
}
|
}
|
||||||
if (rsp.isSuccessful()) {
|
if (rsp.isSuccessful()) {
|
||||||
|
|
@ -102,8 +97,8 @@ public final class OkHttpConnectionFactory {
|
||||||
|
|
||||||
private boolean isExcludedUrl(final Request request) {
|
private boolean isExcludedUrl(final Request request) {
|
||||||
final String requestUrl = request.url().toString();
|
final String requestUrl = request.url().toString();
|
||||||
for (final String url : DO_NOT_INTERCEPT) {
|
for(final String url: DO_NOT_INTERCEPT) {
|
||||||
if (requestUrl.contains(url)) {
|
if(requestUrl.contains(url)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue