-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1、新增自定义下载路径的配置方法;2、新增全局配置自定义Retrofit的Factory方法
- Loading branch information
Showing
8 changed files
with
156 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
library/src/main/java/com/allen/library/config/RetrofitConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.allen.library.config; | ||
|
||
|
||
import retrofit2.CallAdapter; | ||
import retrofit2.Converter; | ||
|
||
|
||
/** | ||
* <pre> | ||
* @author : Allen | ||
* e-mail : [email protected] | ||
* date : 2018/12/08 | ||
* desc : RetrofitFactory的配置 | ||
* version : 1.0 | ||
* </pre> | ||
*/ | ||
public class RetrofitConfig { | ||
|
||
private static RetrofitConfig instance = null; | ||
|
||
|
||
private CallAdapter.Factory[] callAdapterFactory; | ||
|
||
private Converter.Factory[] converterFactory; | ||
|
||
private RetrofitConfig() { | ||
} | ||
|
||
public static RetrofitConfig getInstance() { | ||
|
||
if (instance == null) { | ||
synchronized (RetrofitConfig.class) { | ||
if (instance == null) { | ||
instance = new RetrofitConfig(); | ||
} | ||
} | ||
|
||
} | ||
return instance; | ||
} | ||
|
||
/** | ||
* 添加CallAdapterFactory | ||
* | ||
* @param factories CallAdapter.Factory | ||
*/ | ||
public void addCallAdapterFactory(CallAdapter.Factory... factories) { | ||
this.callAdapterFactory = factories; | ||
|
||
} | ||
|
||
/** | ||
* 添加ConverterFactory | ||
* | ||
* @param factories Converter.Factory | ||
*/ | ||
public void addConverterFactory(Converter.Factory... factories) { | ||
this.converterFactory = factories; | ||
} | ||
|
||
/** | ||
* 获取CallAdapter.Factory | ||
* | ||
* @return | ||
*/ | ||
public CallAdapter.Factory[] getCallAdapterFactory() { | ||
return callAdapterFactory; | ||
} | ||
|
||
/** | ||
* 获取Converter.Factory | ||
* | ||
* @return | ||
*/ | ||
public Converter.Factory[] getConverterFactory() { | ||
return converterFactory; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters