Skip to content

Commit bae927d

Browse files
authored
Add Doc (#510)
1 parent d540bd1 commit bae927d

File tree

99 files changed

+4876
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+4876
-293
lines changed

library/src/androidTest/java/com/qiniu/android/common/CollectConfigTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void testQuick(){
2020
@Test
2121
public void testNormal(){
2222
Config.normal();
23-
assertTrue(Config.uploadThreshold == 4*1024);
23+
assertTrue(Config.uploadThreshold == 16*1024);
2424
assertTrue(Config.interval == 10);
2525
}
2626

library/src/main/java/com/qiniu/android/bigdata/Configuration.java

+26
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44

55
/**
66
* Created by long on 2017/7/25.
7+
*
8+
* @hidden
79
*/
810

911
public final class Configuration implements Cloneable {
12+
13+
/**
14+
* pipelineHost
15+
*/
1016
public String pipelineHost = "https://pipeline.qiniu.com";
1117

18+
/**
19+
* 请求 proxy
20+
*/
1221
public ProxyConfiguration proxy;
1322

1423

@@ -22,6 +31,18 @@ public final class Configuration implements Cloneable {
2231
*/
2332
public int responseTimeout = 10;
2433

34+
/**
35+
* 构造函数
36+
*/
37+
public Configuration() {
38+
}
39+
40+
/**
41+
* Configuration copy
42+
*
43+
* @param config 待 copy 对象
44+
* @return Configuration
45+
*/
2546
public static Configuration copy(Configuration config) {
2647
if (config == null) {
2748
return new Configuration();
@@ -33,6 +54,11 @@ public static Configuration copy(Configuration config) {
3354
}
3455
}
3556

57+
/**
58+
* Configuration clone
59+
*
60+
* @return Configuration
61+
*/
3662
public Configuration clone() throws CloneNotSupportedException {
3763
return (Configuration) super.clone();
3864
}

library/src/main/java/com/qiniu/android/bigdata/client/Client.java

+110-4
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,49 @@
4141

4242
/**
4343
* Created by bailong on 15/11/12.
44+
*
45+
* @hidden
4446
*/
4547
public final class Client {
48+
/**
49+
* HTTP 请求头:Content-Type
50+
*/
4651
public static final String ContentTypeHeader = "Content-Type";
52+
53+
/**
54+
* HTTP 请求默认的 MimeType
55+
*/
4756
public static final String DefaultMime = "application/octet-stream";
57+
58+
/**
59+
* HTTP 请求 Json 的 MimeType
60+
*/
4861
public static final String JsonMime = "application/json";
62+
63+
/**
64+
* HTTP 请求 FormMime 的 MimeType
65+
*/
4966
public static final String FormMime = "application/x-www-form-urlencoded";
67+
5068
private final UrlConverter converter;
5169
private OkHttpClient httpClient;
5270

71+
/**
72+
* 构造方法
73+
*/
5374
public Client() {
5475
this(null, 10, 30, null, null);
5576
}
5677

78+
/**
79+
* 构造函数
80+
*
81+
* @param proxy 请求代理
82+
* @param connectTimeout 请求建立连接超时时间
83+
* @param responseTimeout 请求接收数据超时时间
84+
* @param converter 请求 Url 拦截器
85+
* @param dns 请求的 Dns 解析器
86+
*/
5787
public Client(ProxyConfiguration proxy, int connectTimeout, int responseTimeout, UrlConverter converter, final Dns dns) {
5888
this.converter = converter;
5989
OkHttpClient.Builder builder = new OkHttpClient.Builder();
@@ -71,9 +101,9 @@ public List<InetAddress> lookup(String hostname) throws UnknownHostException {
71101
List<IDnsNetworkAddress> networkAddressList = DnsPrefetcher.getInstance().getInetAddressByHost(hostname);
72102
if (networkAddressList != null && networkAddressList.size() > 0) {
73103
List<InetAddress> inetAddressList = new ArrayList<>();
74-
for (IDnsNetworkAddress networkAddress : networkAddressList){
104+
for (IDnsNetworkAddress networkAddress : networkAddressList) {
75105
InetAddress address = null;
76-
if (networkAddress.getIpValue() != null && (address = InetAddress.getByName(networkAddress.getIpValue())) != null){
106+
if (networkAddress.getIpValue() != null && (address = InetAddress.getByName(networkAddress.getIpValue())) != null) {
77107
inetAddressList.add(address);
78108
}
79109
}
@@ -210,6 +240,15 @@ public void run() {
210240
});
211241
}
212242

243+
/**
244+
* 异步请求
245+
*
246+
* @param requestBuilder 请求构造器
247+
* @param headers 请求头
248+
* @param upToken 上传 Token
249+
* @param totalSize 请求体大小
250+
* @param complete 结束回调
251+
*/
213252
public void asyncSend(final Request.Builder requestBuilder, StringMap headers, final UpToken upToken,
214253
final long totalSize, final CompletionHandler complete) {
215254
if (headers != null) {
@@ -259,13 +298,39 @@ public void onResponse(Call call, okhttp3.Response response) throws IOException
259298
});
260299
}
261300

301+
/**
302+
* 异步 POST 请求
303+
*
304+
* @param url 请求 url
305+
* @param body 请求 body
306+
* @param headers 请求 header
307+
* @param upToken 上传 token
308+
* @param totalSize 请求总大小
309+
* @param progressHandler 请求进度回调
310+
* @param completionHandler 结束回调
311+
* @param c 取消回调
312+
*/
262313
public void asyncPost(String url, byte[] body,
263314
StringMap headers, final UpToken upToken,
264315
final long totalSize, ProgressHandler progressHandler,
265316
CompletionHandler completionHandler, UpCancellationSignal c) {
266317
asyncPost(url, body, 0, body.length, headers, upToken, totalSize, progressHandler, completionHandler, c);
267318
}
268319

320+
/**
321+
* 异步 POST 请求
322+
*
323+
* @param url 请求 Url
324+
* @param body 请求体
325+
* @param offset 请求体偏移量
326+
* @param size 请求体大小
327+
* @param headers 请求 Header
328+
* @param upToken 上传 Token
329+
* @param totalSize 请求体总大小
330+
* @param progressHandler 进度回调
331+
* @param completionHandler 完成回调
332+
* @param c 取消回调
333+
*/
269334
public void asyncPost(String url, byte[] body, int offset, int size,
270335
StringMap headers, final UpToken upToken,
271336
final long totalSize, ProgressHandler progressHandler,
@@ -295,6 +360,16 @@ public void asyncPost(String url, byte[] body, int offset, int size,
295360
asyncSend(requestBuilder, headers, upToken, totalSize, completionHandler);
296361
}
297362

363+
/**
364+
* 异步表单请求
365+
*
366+
* @param url 请求 Url
367+
* @param args 请求参数
368+
* @param upToken 上传的 Token
369+
* @param progressHandler 进度回调
370+
* @param completionHandler 完成回答
371+
* @param c 取消回调
372+
*/
298373
public void asyncMultipartPost(String url,
299374
PostArgs args,
300375
final UpToken upToken,
@@ -343,12 +418,27 @@ public void accept(String key, Object value) {
343418
asyncSend(requestBuilder, null, upToken, totalSize, completionHandler);
344419
}
345420

421+
/**
422+
* 异步 GET 请求
423+
*
424+
* @param url 请求 Url
425+
* @param headers 请求 Header
426+
* @param upToken 上传的 Token
427+
* @param completionHandler 请求完成回调
428+
*/
346429
public void asyncGet(String url, StringMap headers, final UpToken upToken,
347430
CompletionHandler completionHandler) {
348431
Request.Builder requestBuilder = new Request.Builder().get().url(url);
349432
asyncSend(requestBuilder, headers, upToken, 0, completionHandler);
350433
}
351434

435+
/**
436+
* 同步 GET 请求
437+
*
438+
* @param url 请求 Url
439+
* @param headers 请求 Header
440+
* @return ResponseInfo
441+
*/
352442
public ResponseInfo syncGet(String url, StringMap headers) {
353443
Request.Builder requestBuilder = new Request.Builder().get().url(url);
354444
return send(requestBuilder, headers);
@@ -379,8 +469,15 @@ public void accept(String key, Object value) {
379469
return buildResponseInfo(res, tag.ip, tag.duration, null, 0);
380470
}
381471

382-
public ResponseInfo syncMultipartPost(String url, PostArgs args,
383-
final UpToken upToken) {
472+
/**
473+
* 同步表单请求
474+
*
475+
* @param url 请求 Url
476+
* @param args 请求参数
477+
* @param upToken 上传 Token
478+
* @return ResponseInfo
479+
*/
480+
public ResponseInfo syncMultipartPost(String url, PostArgs args, final UpToken upToken) {
384481
RequestBody file;
385482
long totalSize;
386483
if (args.file != null) {
@@ -414,6 +511,15 @@ public void accept(String key, Object value) {
414511
return syncSend(requestBuilder, null, upToken, totalSize);
415512
}
416513

514+
/**
515+
* 同步请求
516+
*
517+
* @param requestBuilder 请求构造器
518+
* @param headers 请求 Header
519+
* @param upToken 上传的 Token
520+
* @param totalSize 请求体大小
521+
* @return ResponseInfo
522+
*/
417523
public ResponseInfo syncSend(final Request.Builder requestBuilder, StringMap headers,
418524
final UpToken upToken, final long totalSize) {
419525
if (headers != null) {

library/src/main/java/com/qiniu/android/bigdata/client/CompletionHandler.java

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/**
88
* 定义请求完成后续动作的处理接口
9+
*
10+
* @hidden
911
*/
1012
public interface CompletionHandler {
1113
/**

library/src/main/java/com/qiniu/android/bigdata/client/PostArgs.java

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/**
88
* 定义请求参数列表
9+
*
10+
* @hidden
911
*/
1012
public final class PostArgs {
1113
/**
@@ -29,4 +31,10 @@ public final class PostArgs {
2931
*/
3032
public String mimeType;
3133

34+
/**
35+
* 构造函数
36+
*/
37+
public PostArgs() {
38+
}
39+
3240
}

0 commit comments

Comments
 (0)