finish part of authorize logic and retrofit add function

This commit is contained in:
unknown
2020-03-26 18:23:16 +08:00
parent df3d31b9b6
commit 207f7eb771
27 changed files with 386 additions and 146 deletions

View File

@@ -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;
}
}