Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RestServiceClass {
- public static final String BASE_URL = "";
- private static Retrofit retrofit = null;
- public static Retrofit getClient() {
- OkHttpClient client = new OkHttpClient.Builder().proxy(proxy).build();*/
- final OkHttpClient okHttpClient = new OkHttpClient.Builder()
- .readTimeout(60, TimeUnit.SECONDS)
- .connectTimeout(60, TimeUnit.SECONDS)
- .writeTimeout(60, TimeUnit.SECONDS)
- .build();
- if (retrofit == null) {
- retrofit = new Retrofit.Builder()
- .baseUrl(BASE_URL)
- .addConverterFactory(GsonConverterFactory.create())
- .client(okHttpClient)
- .build();
- }
- return retrofit;
- }
- public static boolean isNetworkAvailable(Context context){
- ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(context.CONNECTIVITY_SERVICE);
- NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
- return networkInfo != null && networkInfo.isConnected();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement