Skip to content

Commit 36a90ea

Browse files
author
liuyongkui
committed
扩展更多api,并统一调用格式。
1 parent de16066 commit 36a90ea

22 files changed

+1315
-180
lines changed

novate/src/main/java/com/tamic/novate/BaseApiService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import retrofit2.http.*;
2525
import rx.Observable;
2626

27+
import java.util.List;
2728
import java.util.Map;
2829

2930
/**
@@ -81,11 +82,18 @@ Observable<ResponseBody> uploadFlieWithPart(
8182
@Url String fileUrl,
8283
@Part()MultipartBody.Part file);
8384

85+
@Multipart
86+
@POST()
87+
Observable<ResponseBody> uploadFlieWithPartList(
88+
@Url String fileUrl,
89+
@Part List<MultipartBody.Part> list);
90+
91+
8492
@Multipart
8593
@POST()
8694
Observable<ResponseBody> uploadFlieWithPartMap(
8795
@Url String fileUrl,
88-
@PartMap() Map<String, MultipartBody.Part> maps);
96+
@PartMap Map<String, MultipartBody.Part> maps);
8997

9098

9199
@POST()
@@ -98,7 +106,7 @@ Observable<ResponseBody> uploadFile(
98106
Observable<ResponseBody> uploadFileWithPartMap(
99107
@Url() String url,
100108
@PartMap() Map<String, RequestBody> partMap,
101-
@Part("file") MultipartBody.Part file);
109+
@Part() MultipartBody.Part file);
102110

103111
@Streaming
104112
@GET
@@ -119,12 +127,10 @@ <T> Observable<ResponseBody> postForm(
119127
@Url() String url,
120128
@FieldMap Map<String, Object> maps);
121129

122-
123130
@POST()
124131
Observable<ResponseBody> postRequestBody(
125132
@Url() String url,
126133
@Body RequestBody Body);
127-
128134
}
129135

130136

novate/src/main/java/com/tamic/novate/CacheInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public Response intercept(Chain chain) throws IOException {
6767
okhttp3.Response originalResponse = chain.proceed(chain.request());
6868
String cacheControl = originalResponse.header("Cache-Control");
6969
//String cacheControl = request.cacheControl().toString();
70-
LogWraper.e("Novate", maxStaleOnline + "s load cache:" + cacheControl);
70+
LogWraper.d("Novate", maxStaleOnline + "s load cache:" + cacheControl);
7171
if (TextUtils.isEmpty(cacheControl) || cacheControl.contains("no-store") || cacheControl.contains("no-cache") ||
7272
cacheControl.contains("must-revalidate") || cacheControl.contains("max-age") || cacheControl.contains("max-stale")) {
7373
return originalResponse.newBuilder()

novate/src/main/java/com/tamic/novate/CacheInterceptorOffline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public Response intercept(Chain chain) throws IOException {
5353
LogWraper.d("Novate", "request tag :" + request.tag().toString());
5454
LogWraper.d("Novate", "request header :" + request.headers().toString());
5555
if (!NetworkUtil.isNetworkAvailable(context)) {
56-
LogWraper.e("Novate", " no network load cache:"+ request.cacheControl().toString());
56+
LogWraper.d("Novate", " no network load cache:"+ request.cacheControl().toString());
5757
/* request = request.newBuilder()
5858
.removeHeader("Pragma")
5959
.header("Cache-Control", "only-if-cached, " + cacheControlValue_Offline)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.tamic.novate;
2+
3+
import static okhttp3.MultipartBody.FORM;
4+
5+
/**
6+
* Created by Tamic on 2017-06-23.
7+
*/
8+
public enum ContentType {
9+
10+
/**
11+
* application/json
12+
*/
13+
JSON,
14+
/**
15+
*text
16+
*/
17+
TEXT,
18+
/**
19+
*AUDIO
20+
*/
21+
AUDIO,
22+
/**
23+
*
24+
*/
25+
VIDEO,
26+
/**
27+
*image
28+
*/
29+
IMAGE,
30+
/**
31+
*java
32+
*/
33+
JAVA,
34+
/**
35+
*msg
36+
*/
37+
MESSAGE,
38+
/**
39+
*application/vnd.android.package-archive
40+
*/
41+
APK,
42+
/**
43+
*multipart/form-data
44+
*/
45+
FORM
46+
}

0 commit comments

Comments
 (0)