本文整理汇总了Java中com.zhy.http.okhttp.callback.ResultCallback类的典型用法代码示例。如果您正苦于以下问题:Java ResultCallback类的具体用法?Java ResultCallback怎么用?Java ResultCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResultCallback类属于com.zhy.http.okhttp.callback包,在下文中一共展示了ResultCallback类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
public OkHttpRequest get(ResultCallback callback)
{
if (params!=null) {
if (url.endsWith("/")) url=url.substring(0,url.length()-1);
url+="?";
//拼get url
for (Map.Entry<String, String> entry : params.entrySet()) {
String key=entry.getKey();
String value= entry.getValue();
url=url+key+"="+value+"&";
}
url=url.substring(0,url.length()-1);
}
OkHttpRequest request = new OkHttpGetRequest(url, tag, params, headers);
request.invokeAsyn(callback);
return request;
}
示例2: wrapRequestBody
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
@Override
protected RequestBody wrapRequestBody(RequestBody requestBody, final ResultCallback callback)
{
CountingRequestBody countingRequestBody = new CountingRequestBody(requestBody, new CountingRequestBody.Listener()
{
@Override
public void onRequestProgress(final long bytesWritten, final long contentLength)
{
mOkHttpClientManager.getDelivery().post(new Runnable()
{
@Override
public void run()
{
callback.inProgress(bytesWritten * 1.0f / contentLength);
}
});
}
});
return countingRequestBody;
}
示例3: AVGet
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
/**
* AV get请求
*
* @param clazz
* @param lastTime
* @param callback
*/
public static void AVGet(String clazz, String lastTime, ResultCallback callback) {
String url = BASE_URL + clazz + "?limit=10&&order=-createAt";
if (!TextUtils.isEmpty(lastTime)) {
url += "&&where={\"createdAt\":{\"$lt\":{\"__type\":\"Date\",\"iso\":\"" + lastTime + "\"}}}";
}
String time = String.valueOf(System.currentTimeMillis());
String sign = EncodeUtil.md5(time + Global.AV_APP_KEY) + "," + time;
new OkHttpRequest.Builder()
.addHeader("Content-Type", "application/json")
.addHeader("X-LC-Sign", sign)
.addHeader("X-LC-Id", Global.AV_APP_ID)
.url(url)
.get(callback);
}
示例4: sendFailResultCallback
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
public void sendFailResultCallback(final Request request, final Exception e, final ResultCallback callback)
{
if (callback == null) return;
mDelivery.post(new Runnable()
{
@Override
public void run()
{
callback.onError(request, e);
callback.onAfter();
}
});
}
示例5: sendSuccessResultCallback
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
public void sendSuccessResultCallback(final Object object, final ResultCallback callback)
{
if (callback == null) return;
mDelivery.post(new Runnable()
{
@Override
public void run()
{
callback.onResponse(object);
callback.onAfter();
}
});
}
示例6: prepareInvoked
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
protected void prepareInvoked(ResultCallback callback)
{
requestBody = buildRequestBody();
requestBody = wrapRequestBody(requestBody, callback);
request = buildRequest();
}
示例7: invokeAsyn
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
public void invokeAsyn(ResultCallback callback)
{
prepareInvoked(callback);
mOkHttpClientManager.execute(request, callback);
}
示例8: wrapRequestBody
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
protected RequestBody wrapRequestBody(RequestBody requestBody, final ResultCallback callback)
{
return requestBody;
}
示例9: post
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
public OkHttpRequest post(ResultCallback callback)
{
OkHttpRequest request = new OkHttpPostRequest(url, tag, params, headers, mediaType, content, bytes, file);
request.invokeAsyn(callback);
return request;
}
示例10: upload
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
public OkHttpRequest upload(ResultCallback callback)
{
OkHttpRequest request = new OkHttpUploadRequest(url, tag, params, headers, files);
request.invokeAsyn(callback);
return request;
}
示例11: download
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
public OkHttpRequest download(ResultCallback callback)
{
OkHttpRequest request = new OkHttpDownloadRequest(url, tag, params, headers, destFileName, destFileDir);
request.invokeAsyn(callback);
return request;
}
示例12: displayImage
import com.zhy.http.okhttp.callback.ResultCallback; //导入依赖的package包/类
public void displayImage(ResultCallback callback)
{
OkHttpRequest request = new OkHttpDisplayImgRequest(url, tag, params, headers, imageView, errorResId);
request.invokeAsyn(callback);
}