public static RemoteService makeRemoteService() { HttpLoggingInterceptor logging = new HttpLoggingInterceptor( new HttpLoggingInterceptor.Logger() { @Override public void log(String message) { LogUtils.d(TAG, message); } }); logging.setLevel( BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(new SpecialInterceptor()) .addInterceptor(logging) .build(); Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(RemoteService.ENDPOINT) .client(okHttpClient) .addConverterFactory(GsonConverterFactory.create(gson)) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build(); return retrofit.create(RemoteService.class); }
@Override protected void processLogic(Bundle savedInstanceState) { mRemoteServerEngine = new Retrofit.Builder() .baseUrl("http://7xk9dj.com1.z0.glb.clouddn.com/") .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build() .create(RemoteServerEngine.class); }