NIMSDK-AOS
9.19.0
basesdk
src
com
netease
nimlib
sdk
RequestCallbackWrapper.java
浏览该文件的文档.
1
package
com.netease.nimlib.sdk;
2
3
/**
4
* RequestCallback的一个包裹类,将3个结果的调用转到一个接口上,以供上层调用者精简代码,不必每次调用都需要实现3个接口。<br>
5
* 对应到原来的3个接口,参数分别为:<br>
6
* onSuccess(T result) -> onResult(ResponseCode.RES_SUCCESS, result, null)<br>
7
* onFailed(int code) -> onResult(code, null, null)<br>
8
* onException(Throwable exception) -> onResult(ResponseCode.RES_EXCEPTION, null, exception)<br>
9
*/
10
public
abstract
class
RequestCallbackWrapper
<T>
implements
RequestCallback
<T> {
11
12
/**
13
* 调用结果回调函数
14
* @param code
15
* @param result
16
* @param exception
17
*/
18
public
abstract
void
onResult
(
int
code, T result, Throwable exception);
19
20
@Override
21
public
void
onSuccess
(T result) {
22
onResult
(
ResponseCode
.
RES_SUCCESS
, result, null);
23
}
24
25
@Override
26
public
void
onFailed
(
int
code) {
27
onResult
(code, null, null);
28
}
29
30
@Override
31
public
void
onException
(Throwable exception) {
32
exception.printStackTrace();
33
onResult
(
ResponseCode
.
RES_EXCEPTION
, null, exception);
34
}
35
}
com.netease.nimlib.sdk.ResponseCode
云信服务器主要响应码定义
Definition:
ResponseCode.java:6
com.netease.nimlib.sdk.ResponseCode.RES_EXCEPTION
static final short RES_EXCEPTION
操作出现异常
Definition:
ResponseCode.java:320
com.netease.nimlib.sdk.RequestCallbackWrapper.onResult
abstract void onResult(int code, T result, Throwable exception)
调用结果回调函数
com.netease.nimlib.sdk.RequestCallbackWrapper.onFailed
void onFailed(int code)
操作失败
Definition:
RequestCallbackWrapper.java:26
com.netease.nimlib.sdk.RequestCallbackWrapper.onSuccess
void onSuccess(T result)
操作成功
Definition:
RequestCallbackWrapper.java:21
com.netease.nimlib.sdk.RequestCallbackWrapper.onException
void onException(Throwable exception)
操作过程中发生异常
Definition:
RequestCallbackWrapper.java:31
com.netease.nimlib.sdk.ResponseCode.RES_SUCCESS
static final short RES_SUCCESS
操作成功
Definition:
ResponseCode.java:11
com.netease.nimlib.sdk.RequestCallback
请求回调接口
Definition:
RequestCallback.java:6
com.netease.nimlib.sdk.RequestCallbackWrapper
RequestCallback的一个包裹类,将3个结果的调用转到一个接口上,以供上层调用者精简代码,不必每次调用都需...
Definition:
RequestCallbackWrapper.java:10
生成于 2024年 十月 16日 星期三 10:25:05 , 为 NIMSDK-AOS使用
1.8.13