本文整理汇总了Java中com.lzy.okgo.OkGo.getCommonParams方法的典型用法代码示例。如果您正苦于以下问题:Java OkGo.getCommonParams方法的具体用法?Java OkGo.getCommonParams怎么用?Java OkGo.getCommonParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lzy.okgo.OkGo
的用法示例。
在下文中一共展示了OkGo.getCommonParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Request
import com.lzy.okgo.OkGo; //导入方法依赖的package包/类
public Request(String url) {
this.url = url;
baseUrl = url;
OkGo go = OkGo.getInstance();
//默认添加 Accept-Language
String acceptLanguage = HttpHeaders.getAcceptLanguage();
if (!TextUtils.isEmpty(acceptLanguage)) headers(HttpHeaders.HEAD_KEY_ACCEPT_LANGUAGE, acceptLanguage);
//默认添加 User-Agent
String userAgent = HttpHeaders.getUserAgent();
if (!TextUtils.isEmpty(userAgent)) headers(HttpHeaders.HEAD_KEY_USER_AGENT, userAgent);
//添加公共请求参数
if (go.getCommonParams() != null) params(go.getCommonParams());
if (go.getCommonHeaders() != null) headers(go.getCommonHeaders());
//添加缓存模式
retryCount = go.getRetryCount();
cacheMode = go.getCacheMode();
cacheTime = go.getCacheTime();
}
示例2: BaseRequest
import com.lzy.okgo.OkGo; //导入方法依赖的package包/类
public BaseRequest(String url) {
this.url = url;
baseUrl = url;
OkGo go = OkGo.getInstance();
//默认添加 Accept-Language
String acceptLanguage = HttpHeaders.getAcceptLanguage();
if (!TextUtils.isEmpty(acceptLanguage)) headers(HttpHeaders.HEAD_KEY_ACCEPT_LANGUAGE, acceptLanguage);
//默认添加 User-Agent
String userAgent = HttpHeaders.getUserAgent();
if (!TextUtils.isEmpty(userAgent)) headers(HttpHeaders.HEAD_KEY_USER_AGENT, userAgent);
//添加公共请求参数
if (go.getCommonParams() != null) params.put(go.getCommonParams());
if (go.getCommonHeaders() != null) headers.put(go.getCommonHeaders());
//添加缓存模式
if (go.getCacheMode() != null) cacheMode = go.getCacheMode();
cacheTime = go.getCacheTime();
//超时重试次数
retryCount = go.getRetryCount();
}