SHARE
TWEET

Untitled

a guest Feb 20th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SolidClient {
  2.  
  3.     private static SolidService service;
  4.     private static Retrofit retrofit;
  5.  
  6.     private static SolidService createService() {
  7.         return getRetrofit().create(SolidService.class);
  8.     }
  9.  
  10.     private static Retrofit getRetrofit() {
  11.         if (retrofit == null) {
  12.             retrofit = new Retrofit.Builder()
  13.                     .client(getOkHttp())
  14.                     .addConverterFactory(MoshiConverterFactory.create())
  15.                     .baseUrl("http://www.mocky.io/")
  16.                     .build();
  17.         }
  18.         return retrofit;
  19.     }
  20.  
  21.     private static OkHttpClient getOkHttp() {
  22.         return new OkHttpClient.Builder()
  23.                 .connectTimeout(30, TimeUnit.SECONDS)
  24.                 .readTimeout(30, TimeUnit.SECONDS)
  25.                 .writeTimeout(30, TimeUnit.SECONDS)
  26.                 .addInterceptor(new HttpLoggingInterceptor()
  27.                         .setLevel(HttpLoggingInterceptor.Level.BODY))
  28.                 .build();
  29.     }
  30.  
  31.     private static SolidService getService() {
  32.         return service == null ? service = createService() : service;
  33.     }
  34.  
  35.  
  36.     public static void getListOfMalls(Callback<GetListOfMallsResponse> cb) {
  37.         getService().getListOfMalls().enqueue(cb);
  38.     }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top