finish part of authorize logic and retrofit add function
This commit is contained in:
@@ -11,22 +11,36 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public final class RetrofitFactory {
|
||||
|
||||
private static final Map< String, Retrofit> sRpcServiceMap = new ArrayMap< String,Retrofit>();
|
||||
private static final Map<String, Retrofit> sRpcServiceMap = new ArrayMap<String, Retrofit>();
|
||||
private static final Map<String, Retrofit> sRpcNoAdapterServiceMap = new ArrayMap<String, Retrofit>();
|
||||
|
||||
private RetrofitFactory(){}
|
||||
private RetrofitFactory() {
|
||||
}
|
||||
|
||||
public static synchronized Retrofit getInstance( String baseUrl) {
|
||||
public static synchronized Retrofit getInstance(String baseUrl) {
|
||||
Retrofit target = sRpcServiceMap.get(baseUrl);
|
||||
if(target == null){
|
||||
if (target == null) {
|
||||
target = new Retrofit.Builder().
|
||||
client(OkHttpFactory.getInstance()).
|
||||
baseUrl(baseUrl).
|
||||
addCallAdapterFactory( RxJava2CallAdapterFactory.create()).
|
||||
addCallAdapterFactory(RxJava2CallAdapterFactory.create()).
|
||||
addConverterFactory(GsonConverterFactory.create()).
|
||||
build();
|
||||
sRpcServiceMap.put(baseUrl,target);
|
||||
sRpcServiceMap.put(baseUrl, target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
public static synchronized Retrofit getInstanceNoCallAdapter(String baseUrl) {
|
||||
Retrofit target = sRpcNoAdapterServiceMap.get(baseUrl);
|
||||
if (target == null) {
|
||||
target = new Retrofit.Builder().
|
||||
client(OkHttpFactory.getInstance()).
|
||||
baseUrl(baseUrl).
|
||||
addConverterFactory(GsonConverterFactory.create()).
|
||||
build();
|
||||
sRpcNoAdapterServiceMap.put(baseUrl, target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user