use of com.zimincom.mafiaonline.PersistentCookieStore in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class ServiceGenerator method createService.
public static <S> S createService(Class<S> serviceClass, Context context) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
if (BuildConfig.DEBUG) {
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
logging.setLevel(HttpLoggingInterceptor.Level.NONE);
}
PersistentCookieStore cookieStore = new PersistentCookieStore(context);
java.net.CookieManager cookieManager = new java.net.CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder().cookieJar(new JavaNetCookieJar(cookieManager)).addInterceptor(logging).addNetworkInterceptor(new StethoInterceptor());
Gson gson = new GsonBuilder().setLenient().create();
Retrofit retorfit = new Retrofit.Builder().baseUrl(MafiaRemoteService.BASE_URL).addConverterFactory(GsonConverterFactory.create(gson)).client(httpClient.build()).build();
return retorfit.create(serviceClass);
}
Aggregations