Skip to content

Commit 47eb4a2

Browse files
committed
fork okhttp-gson code template
1 parent e750b98 commit 47eb4a2

11 files changed

+2268
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{>licenseInfo}}
2+
3+
package {{invokerPackage}};
4+
5+
import java.io.IOException;
6+
7+
import java.util.Map;
8+
import java.util.List;
9+
10+
/**
11+
* Callback for asynchronous API call.
12+
*
13+
* @param <T> The return type
14+
*/
15+
public interface ApiCallback<T> {
16+
/**
17+
* This is called when the API call fails.
18+
*
19+
* @param e The exception causing the failure
20+
* @param statusCode Status code of the response if available, otherwise it would be 0
21+
* @param responseHeaders Headers of the response if available, otherwise it would be null
22+
*/
23+
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);
24+
25+
/**
26+
* This is called when the API call succeeded.
27+
*
28+
* @param result The result deserialized from response
29+
* @param statusCode Status code of the response
30+
* @param responseHeaders Headers of the response
31+
*/
32+
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);
33+
34+
/**
35+
* This is called when the API upload processing.
36+
*
37+
* @param bytesWritten bytes Written
38+
* @param contentLength content length of request body
39+
* @param done write end
40+
*/
41+
void onUploadProgress(long bytesWritten, long contentLength, boolean done);
42+
43+
/**
44+
* This is called when the API downlond processing.
45+
*
46+
* @param bytesRead bytes Read
47+
* @param contentLength content lenngth of the response
48+
* @param done Read end
49+
*/
50+
void onDownloadProgress(long bytesRead, long contentLength, boolean done);
51+
}

0 commit comments

Comments
 (0)