代码拉取完成,页面将自动刷新
通过library生成har包,添加har包到要集成的libs文件夹内
在entry的gradle内添加如下代码
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
allprojects{
repositories{
mavenCentral()
}
}
implementation "com.gitee.archermind-ti:retrofit-url-manager:1.0.0-beta"
// When building OkHttpClient, the OkHttpClient.Builder() is passed to the with() method to initialize the configuration
this.mOkHttpClient = RetrofitUrlManager.getInstance().with(new OkHttpClient.Builder())
.readTimeout(5, TimeUnit.SECONDS)
.connectTimeout(5, TimeUnit.SECONDS)
.build();
public interface OneApiService {
/**
* 如果不需要多个 BaseUrl, 继续使用初始化时传入 Retrofit 中的默认 BaseUrl, 就不要加上 DOMAIN_NAME_HEADER 这个 Header
*/
@Headers({DOMAIN_NAME_HEADER + GITHUB_DOMAIN_NAME})
/**
* 可以通过在注解里给全路径达到使用不同的 BaseUrl, 但是这样无法在 App 运行时动态切换 BaseUrl
*/
@GET("/users")
Observable<ResponseBody> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// You can change BaseUrl at any time while App is running (The interface that declared the Domain-Name header)
String APP_DOUBAN_DOMAIN = "https://api.douban.com";
RetrofitUrlManager.getInstance().putDomain(DOUBAN_DOMAIN_NAME, APP_DOUBAN_DOMAIN);
// BaseUrl configured in the Domain-Name header will override BaseUrl in the global setting
mGlobalUrl = (TextField) findComponentById(ResourceTable.Id_et_global_url);
RetrofitUrlManager.getInstance().setGlobalDomain(mGlobalUrl.getText().toString().trim());
Copyright 2017, jessyan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。