Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public class RetrofitClient {
  2.  
  3.     private static Retrofit retrofit = null;
  4.     private static Context context;
  5.  
  6.     public RetrofitClient(Context context) {
  7.         this.context = context;
  8.     }
  9.  
  10.         OkHttpClient.Builder builder = new OkHttpClient.Builder();
  11.         OkHttpClient okHttpClient = null;
  12.         okHttpClient = builder.addInterceptor(new AddCookiesInterceptor(context))
  13.                 .addInterceptor(new ReceivedCookiesInterceptor(context))
  14.                 .build();
  15.  
  16.         if (retrofit == null) {
  17.             retrofit = new Retrofit.Builder()
  18.                     .baseUrl(baseUrl)
  19.                     .addConverterFactory(GsonConverterFactory.create())
  20.                     .client(okHttpClient)
  21.                     .build();
  22.         }
  23.         return retrofit;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement