use of org.wikipedia.dataclient.SharedPreferenceCookieManager in project apps-android-wikipedia by wikimedia.
the class CookieManagerTypeAdapter method read.
@Override
public SharedPreferenceCookieManager read(JsonReader in) throws IOException {
Map<String, List<Cookie>> map = new HashMap<>();
in.beginObject();
while (in.hasNext()) {
String key = in.nextName();
List<Cookie> list = new ArrayList<>();
map.put(key, list);
in.beginArray();
HttpUrl url = HttpUrl.parse(WikiSite.DEFAULT_SCHEME + "://" + key);
while (in.hasNext()) {
String str = in.nextString();
if (url != null) {
list.add(Cookie.parse(url, str));
}
}
in.endArray();
}
in.endObject();
return new SharedPreferenceCookieManager(map);
}
use of org.wikipedia.dataclient.SharedPreferenceCookieManager in project apps-android-wikipedia by wikimedia.
the class OkHttpConnectionFactory method createClient.
@NonNull
private static OkHttpClient createClient() {
SharedPreferenceCookieManager cookieManager = SharedPreferenceCookieManager.getInstance();
// TODO: consider using okhttp3.CookieJar implementation instead of JavaNetCookieJar wrapper
CookieJar cookieJar = new JavaNetCookieJar(cookieManager);
return new OkHttpClient.Builder().cookieJar(cookieJar).cache(NET_CACHE).addInterceptor(new HttpLoggingInterceptor().setLevel(Prefs.getRetrofitLogLevel())).addInterceptor(new UnsuccessfulResponseInterceptor()).addInterceptor(new StatusResponseInterceptor(RbSwitch.INSTANCE)).addNetworkInterceptor(new StripMustRevalidateResponseInterceptor()).addInterceptor(new CommonHeaderRequestInterceptor()).addInterceptor(new DefaultMaxStaleRequestInterceptor()).addInterceptor(new CacheControlRequestInterceptor()).addInterceptor(new OfflineCacheInterceptor(SAVE_CACHE)).addInterceptor(new WikipediaZeroResponseInterceptor(WikipediaApp.getInstance().getWikipediaZeroHandler())).addInterceptor(new TestStubInterceptor()).build();
}
Aggregations