提交 7eec9324 编写于 作者: J jessyan

Improve GlobalConfiguration

上级 e9b76866
......@@ -63,10 +63,11 @@ public final class GlobalConfiguration implements ConfigModule {
//请参考 https://github.com/JessYanCoding/MVPArms/wiki#3.4
// .imageLoaderStrategy(new CustomLoaderStrategy())
//想支持多 BaseUrl,以及运行时动态切换任意一个 BaseUrl,请使用 https://github.com/JessYanCoding/RetrofitUrlManager
//如果 BaseUrl 在 App 启动时不能确定,需要请求服务器接口动态获取,请使用以下代码
//以下代码只是配置,还要使用 Okhttp (AppComponent中提供) 请求服务器获取到正确的 BaseUrl 后赋值给 GlobalConfiguration.sDomain
//切记整个过程必须在第一次调用 Retrofit 接口之前完成,如果已经调用过 Retrofit 接口,将不能动态切换 BaseUrl
//想支持多 BaseUrl, 以及运行时动态切换任意一个 BaseUrl, 请使用 https://github.com/JessYanCoding/RetrofitUrlManager
//如果 BaseUrl 在 App 启动时不能确定, 需要请求服务器接口动态获取, 请使用以下代码
//以下方式是 Arms 框架自带的切换 BaseUrl 的方式, 在整个 App 生命周期内只能切换一次, 若需要无限次的切换 BaseUrl, 以及各种复杂的应用场景还是需要使用 RetrofitUrlManager 框架
//以下代码只是配置, 还要使用 Okhttp (AppComponent中提供) 请求服务器获取到正确的 BaseUrl 后赋值给 GlobalConfiguration.sDomain
//切记整个过程必须在第一次调用 Retrofit 接口之前完成, 如果已经调用过 Retrofit 接口, 此种方式将不能切换 BaseUrl
// .baseurl(new BaseUrl() {
// @Override
// public HttpUrl url() {
......@@ -88,6 +89,32 @@ public final class GlobalConfiguration implements ConfigModule {
// return new LruCache(200);
// }
// }
// })
//若觉得框架默认的打印格式并不能满足自己的需求, 可自行扩展自己理想的打印格式 (以下只是简单实现)
// .formatPrinter(new FormatPrinter() {
// @Override
// public void printJsonRequest(Request request, String bodyString) {
// Timber.i("printJsonRequest:" + bodyString);
// }
//
// @Override
// public void printFileRequest(Request request) {
// Timber.i("printFileRequest:" + request.url().toString());
// }
//
// @Override
// public void printJsonResponse(long chainMs, boolean isSuccessful, int code,
// String headers, MediaType contentType, String bodyString,
// List<String> segments, String message, String responseUrl) {
// Timber.i("printJsonResponse:" + bodyString);
// }
//
// @Override
// public void printFileResponse(long chainMs, boolean isSuccessful, int code, String headers,
// List<String> segments, String message, String responseUrl) {
// Timber.i("printFileResponse:" + responseUrl);
// }
// })
// 这里提供一个全局处理 Http 请求和响应结果的处理类,可以比客户端提前一步拿到服务器返回的结果,可以做一些操作,比如token超时,重新获取
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册