| | |
| | | package com.dayu.pipirrapp.net; |
| | | |
| | | |
| | | import com.dayu.pipirrapp.BuildConfig; |
| | | |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | |
| | | public class RetrofitClient { |
| | | |
| | | private static RetrofitClient mInstance; |
| | | private Retrofit retrofit; |
| | | private final Retrofit retrofit; |
| | | private static final int READ_TIME_OUT = 10; |
| | | private static final int CONNECT_TIME_OUT = 10; |
| | | |
| | |
| | | builder.addInterceptor(new MyIntercepterApplication()); |
| | | //添加日志拦截器 |
| | | //添加数据请求统一处理拦截器 |
| | | // if (BuildConfig.DEBUG) { |
| | | builder.addInterceptor(loggingInterceptor); |
| | | // } |
| | | if (BuildConfig.DEBUG) { |
| | | builder.addInterceptor(loggingInterceptor); |
| | | } |
| | | |
| | | OkHttpClient client = builder.build(); |
| | | |
| | | // // 创建GsonBuilder并设置长整型序列化策略为字符串 |
| | | // GsonBuilder gsonBuilder = new GsonBuilder(); |
| | | // gsonBuilder.registerTypeAdapter(String.class, new LongTypeAdapter()); |
| | | // gsonBuilder.registerTypeAdapter(long.class, new LongTypeAdapter()); // 如果是 long 类型的基本数据类型,也需要注册 |
| | | // gsonBuilder.setLongSerializationPolicy(LongSerializationPolicy.STRING); |
| | | //// 创建Gson实例 |
| | | // Gson gson = gsonBuilder.create(); |
| | | retrofit = new Retrofit.Builder() |
| | | .baseUrl(Constants.BASE_URL) |
| | | .addConverterFactory(GsonConverterFactory.create()) |