Skip to content

Commit 1d4f300

Browse files
author
Vens Chen
committed
update readme
1 parent a5b98be commit 1d4f300

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ compile 'com.github.chenthreetrees:thttp:1.0.5'
2929
```
3030

3131

32-
## Retrofit中http POST/GET请求(结合了rx)
32+
## 接口请求
3333
Retrofit中的网络请求都是通过注解方式的接口方法来表示的,此处只对常用的post和get请求进行说明,
3434
Retrofit还提供有put,delete等请求方式可自己研究官方文档使用。
3535

@@ -140,25 +140,27 @@ public class HttpInterceptor implements Interceptor {
140140
### 初始化
141141
```
142142
RetrofitManager.getInstence()
143-
.baseUrl("your baseUrl")
144-
.addInterceptor(new HttpInterceptor())
145-
.serviceClass(ApiService.class)
143+
.baseUrl("your baseUrl")//设置你的baseUrl,不能为空
144+
.addInterceptor(new HttpInterceptor())//添加自己的拦截器,参考retrofit拦截器的使用,可选
145+
.serviceClass(ApiService.class)//设置api接口请求文件,参考上面的接口请求
146+
.debug(true)//是否打印response数据,默认为false
146147
.create();
147148
```
148149

149150
### 业务请求
150-
具体的业务请求类继承HttpPresenter,传入一些配置参数
151+
具体的业务请求类继承HttpPresenter:
151152
```
152153
public class DocPresenter extends HttpPresenter {
153154
private ApiService mApiService;
155+
//ILoadingView: 页面的回调,详细参考demo
154156
public DocPresenter(ILoadingView iLoadingView)
155157
{
156158
super(iLoadingView);
157159
mApiService = (ApiService)RetrofitManager.getInstence().getRetrofitService();
158160
}
159161
160162
/**
161-
* 网络请求的具体实现
163+
* 具体业务的网络请求
162164
*/
163165
public void getDoc()
164166
{
@@ -206,9 +208,10 @@ DocPresenter docPresenter = new DocPresenter(new ILoadingView() {
206208
}
207209
208210
});
211+
docPresenter.getDoc();
209212
```
210213

211-
上面的代码看起来还是不够简洁,建议根据业务需求进一步封装基类
214+
上面的代码看起来还是不够简洁,建议根据业务需求进一步封装基类,参考demo。
212215

213216
### 文件下载
214217
```

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ dependencies {
3030

3131
compile project(":tthttp")
3232
compile 'com.github.chenthreetrees:tdialog:1.0.0'
33-
// compile 'com.github.chenthreetrees:thttp:1.0.1'
33+
// compile 'com.github.chenthreetrees:thttp:1.0.5'
3434
}

0 commit comments

Comments
 (0)