本文整理了Java中retrofit2.Retrofit.newBuilder
方法的一些代码示例,展示了Retrofit.newBuilder
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Retrofit.newBuilder
方法的具体详情如下:
包路径:retrofit2.Retrofit
类名称:Retrofit
方法名:newBuilder
暂无
代码示例来源:origin: influxdata/influxdb-java
Retrofit.Builder clonedRetrofitBuilder = retrofitBuilder.baseUrl(url).build().newBuilder();
this.retrofit = clonedRetrofitBuilder.client(clonedOkHttpBuilder.build())
.addConverterFactory(converterFactory).build();
代码示例来源:origin: org.nuxeo.client/nuxeo-java-client
/**
* Replaces the input {@link AbstractBase} into this one. This method will create a new retrofit object in order to
* correctly isolate this configuration.
* <p />
* DON'T REMOVE FINAL KEYWORD, THIS METHOD IS USED IN A CONSTRUCTOR.
*
* @param base the base to replace
*/
protected final void replaceWith(AbstractBase<?> base) {
// in order to have a retrofit instance and correctly isolate this configuration from the copied one, we build
// retrofit
OkHttpClient okhttp = base.okhttpBuilder.build();
retrofit = base.retrofitBuilder.callFactory(okhttp).build();
// get new builders
// okhttp builder
okhttpBuilder = okhttp.newBuilder();
// retrofit builder
retrofitBuilder = retrofit.newBuilder();
// copy header interceptors
headerInterceptors = new HashMap<>();
headerInterceptors.putAll(base.headerInterceptors);
// copy header values
headerValues = new HashMap<>();
headerValues.putAll(base.headerValues);
}
代码示例来源:origin: cn.leancloud/storage-core
private Observable<RTMConnectionServerResponse> fetchRTMServerFromRemote(final String routerHost, final String appId,
final String installationId, int secure) {
LOGGER.d("fetchRTMServerFromRemote. router=" + routerHost + ", appId=" + appId);
Retrofit tmpRetrofit = retrofit.newBuilder().baseUrl(routerHost).build();
AppRouterService tmpService = tmpRetrofit.create(AppRouterService.class);
Observable<RTMConnectionServerResponse> result = tmpService.getRTMConnectionServer(appId, installationId, secure);
if (AppConfiguration.isAsynchronized()) {
result = result.subscribeOn(Schedulers.io());
}
AppConfiguration.SchedulerCreator creator = AppConfiguration.getDefaultScheduler();
if (null != creator) {
result = result.observeOn(creator.create());
}
return result.map(new Function<RTMConnectionServerResponse, RTMConnectionServerResponse>() {
@Override
public RTMConnectionServerResponse apply(RTMConnectionServerResponse rtmConnectionServerResponse) throws Exception {
SystemSetting setting = AppConfiguration.getDefaultSetting();
if (null != rtmConnectionServerResponse && null != setting) {
rtmConnectionServerResponse.setTtl(rtmConnectionServerResponse.getTtl() + System.currentTimeMillis() / 1000);
String cacheResult = JSON.toJSONString(rtmConnectionServerResponse);
setting.saveString(getPersistenceKeyZone(appId, false), routerHost, cacheResult);
}
return rtmConnectionServerResponse;
}
});
}
代码示例来源:origin: org.influxdb/influxdb-java
Retrofit.Builder clonedRetrofitBuilder = retrofitBuilder.baseUrl(url).build().newBuilder();
this.retrofit = clonedRetrofitBuilder.client(this.client)
.addConverterFactory(converterFactory).build();
内容来源于网络,如有侵权,请联系作者删除!