Search in sources :

Example 1 with LoggingInterceptor

use of org.michenux.drodrolib.network.okhttp.LoggingInterceptor in project YourAppIdea by Michenux.

the class MongolabPlaceServiceFactory method create.

public static MongolabPlaceService create(Context context) {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(Timestamp.class, new TimestampDeserializer());
    gsonBuilder.registerTypeAdapter(Location.class, new LocationDeserializer());
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new LoggingInterceptor()).build();
    String url = context.getString(R.string.aroundme_placeremoteprovider_url);
    Retrofit retrofit = new Retrofit.Builder().baseUrl(url).client(client).addConverterFactory(GsonConverterFactory.create(gsonBuilder.create())).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
    return retrofit.create(MongolabPlaceService.class);
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) LoggingInterceptor(org.michenux.drodrolib.network.okhttp.LoggingInterceptor) TimestampDeserializer(org.michenux.drodrolib.network.gson.TimestampDeserializer) GsonBuilder(com.google.gson.GsonBuilder) GsonBuilder(com.google.gson.GsonBuilder) LocationDeserializer(org.michenux.drodrolib.network.gson.LocationDeserializer)

Example 2 with LoggingInterceptor

use of org.michenux.drodrolib.network.okhttp.LoggingInterceptor in project YourAppIdea by Michenux.

the class AirportInfoServiceFactory method create.

public static AirportInfoService create(Context context) {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(Timestamp.class, new TimestampDeserializer());
    gsonBuilder.registerTypeAdapter(Location.class, new LocationDeserializer());
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new LoggingInterceptor()).build();
    Retrofit retrofit = new Retrofit.Builder().baseUrl(context.getString(R.string.airport_rest_url)).client(client).addConverterFactory(GsonConverterFactory.create(gsonBuilder.create())).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
    return retrofit.create(AirportInfoService.class);
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) LoggingInterceptor(org.michenux.drodrolib.network.okhttp.LoggingInterceptor) TimestampDeserializer(org.michenux.drodrolib.network.gson.TimestampDeserializer) GsonBuilder(com.google.gson.GsonBuilder) GsonBuilder(com.google.gson.GsonBuilder) LocationDeserializer(org.michenux.drodrolib.network.gson.LocationDeserializer)

Example 3 with LoggingInterceptor

use of org.michenux.drodrolib.network.okhttp.LoggingInterceptor in project YourAppIdea by Michenux.

the class WordpressServiceFactory method create.

public static WordpressService create(Context context) {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(Timestamp.class, new TimestampDeserializer());
    gsonBuilder.registerTypeAdapter(Location.class, new LocationDeserializer());
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new LoggingInterceptor()).build();
    Retrofit retrofit = new Retrofit.Builder().baseUrl(context.getString(R.string.tutorial_sync_url)).client(client).addConverterFactory(GsonConverterFactory.create(gsonBuilder.create())).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
    return retrofit.create(WordpressService.class);
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) LoggingInterceptor(org.michenux.drodrolib.network.okhttp.LoggingInterceptor) TimestampDeserializer(org.michenux.drodrolib.network.gson.TimestampDeserializer) GsonBuilder(com.google.gson.GsonBuilder) GsonBuilder(com.google.gson.GsonBuilder) LocationDeserializer(org.michenux.drodrolib.network.gson.LocationDeserializer)

Aggregations

GsonBuilder (com.google.gson.GsonBuilder)3 OkHttpClient (okhttp3.OkHttpClient)3 LocationDeserializer (org.michenux.drodrolib.network.gson.LocationDeserializer)3 TimestampDeserializer (org.michenux.drodrolib.network.gson.TimestampDeserializer)3 LoggingInterceptor (org.michenux.drodrolib.network.okhttp.LoggingInterceptor)3 Retrofit (retrofit2.Retrofit)3