use of cn.jeesoft.qa.libcore.http.QAHttpCallback in project QuickAndroid by ImKarl.
the class OkHttp method load.
/**
* 异步请求
*
* @param method
* @param url
* @param params
* @param listener
* @param <T>
*/
public <T> void load(QAHttpMethod method, final String url, final QARequestParams params, final QAHttpCallback<T> listener) {
final Request request = createRequest(method, url, params, listener);
if (request == null) {
return;
}
if (params != null && params.isPreLoad()) {
// 缓存加载
preLoad(url, params, request, listener);
}
// 网络加载
mOkHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(final Request request, final IOException e) {
sendFailedCallback(url, e, listener);
}
@Override
public void onResponse(final Response response) {
handlerResponse(url, params, response, listener);
}
});
}
Aggregations