| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import okhttp3.Interceptor; |
| | | import okhttp3.OkHttpClient; |
| | | import retrofit2.Retrofit; |
| | | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; |
| | |
| | | */ |
| | | public class RetrofitManager { |
| | | |
| | | private static RetrofitManager instance; |
| | | private static volatile RetrofitManager instance; |
| | | private final Map<String,Retrofit> retrofitMap; |
| | | private OkHttpClient mClient; |
| | | |
| | | public static RetrofitManager getInstance(){ |
| | | if (instance == null){ |
| | | instance = new RetrofitManager(); |
| | | if (instance == null) { |
| | | synchronized (RetrofitManager.class) { |
| | | if (instance == null) { |
| | | instance = new RetrofitManager(); |
| | | } |
| | | } |
| | | } |
| | | return instance; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 设置 OkHttpClient |
| | | * 设置 自定义OkHttpClient |
| | | */ |
| | | public RetrofitManager setOkHttpClient(OkHttpClient client) { |
| | | this.mClient = client; |
| | | return instance; |
| | | } |
| | | |
| | | |
| | | } |