-
Notifications
You must be signed in to change notification settings - Fork 286
请求回调详解
Jianbo Peng edited this page Feb 18, 2016
·
2 revisions
//请求开始执行
public void onStart() {}
//请求相应
public void onResponse(String response, Headers headers) {}
//请求成功-带响应Header信息
protected void onSuccess(Headers headers, T t) {}
//请求成功
protected void onSuccess(T t) {}
//写入流进度
public void onProgress(int progress, long networkSpeed, boolean done){}
//请求失败
public void onFailure(int errorCode, String msg) {}
//请求完成
public void onFinish() {}
//获取响应Header
public Headers getHeaders() {}
回调执行顺序 onStart->onProgress->onResponse->onSuccess/onFailure->onFinish
OkHttpFinal自带有BaseHttpRequestCallback<T>、StringHttpRequestCallback、JsonArrayHttpRequestCallback、JsonHttpRequestCallback回调实现。开发者根据需求选择