use of com.eveningoutpost.dexdrip.tidepool.InfoInterceptor in project xDrip-plus by jamorham.
the class NightscoutFollow method getRetrofitInstance.
// TODO make reusable
public static Retrofit getRetrofitInstance() throws IllegalArgumentException {
if (retrofit == null) {
final String url = getUrl();
if (emptyString(url)) {
UserError.Log.d(TAG, "Empty url - cannot create instance");
return null;
}
final HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
if (D) {
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
}
final OkHttpClient client = enableTls12OnPreLollipop(new OkHttpClient.Builder()).addInterceptor(httpLoggingInterceptor).addInterceptor(new InfoInterceptor(TAG)).addInterceptor(new GzipRequestInterceptor()).build();
final Gson gson = new GsonBuilder().registerTypeAdapterFactory(UNRELIABLE_INTEGER_FACTORY).create();
retrofit = new retrofit2.Retrofit.Builder().baseUrl(url).client(client).addConverterFactory(GsonConverterFactory.create(gson)).build();
}
return retrofit;
}
Aggregations