Search in sources :

Example 6 with InfoInterceptor

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;
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) GsonBuilder(com.google.gson.GsonBuilder) InfoInterceptor(com.eveningoutpost.dexdrip.tidepool.InfoInterceptor) Gson(com.google.gson.Gson) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor)

Aggregations

InfoInterceptor (com.eveningoutpost.dexdrip.tidepool.InfoInterceptor)6 OkHttpClient (okhttp3.OkHttpClient)6 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)6 Retrofit (retrofit2.Retrofit)6 GsonBuilder (com.google.gson.GsonBuilder)4 Dex_Constants (com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.Dex_Constants)2 JoH.emptyString (com.eveningoutpost.dexdrip.Models.JoH.emptyString)2 GzipRequestInterceptor (com.eveningoutpost.dexdrip.cgm.nsfollow.GzipRequestInterceptor)2 Gson (com.google.gson.Gson)2