use of com.okhttplib.HttpInfo in project OkHttp3 by MrZhousf.
the class DownloadBreakpointsActivity method download.
private void download() {
if (null == fileInfo)
fileInfo = new DownloadFileInfo(url, "test", new ProgressCallback() {
@Override
public void onProgressMain(int percent, long bytesWritten, long contentLength, boolean done) {
downloadProgress.setProgress(percent);
tvResult.setText(percent + "%");
LogUtil.d(TAG, "下载进度:" + percent);
}
@Override
public void onResponseMain(String filePath, HttpInfo info) {
if (info.isSuccessful()) {
tvResult.setText(info.getRetDetail() + "\n下载状态:" + fileInfo.getDownloadStatus());
} else {
Toast.makeText(DownloadBreakpointsActivity.this, info.getRetDetail(), Toast.LENGTH_SHORT).show();
}
}
});
HttpInfo info = HttpInfo.Builder().addDownloadFile(fileInfo).build();
OkHttpUtil.Builder().setReadTimeout(120).build(this).doDownloadFileAsync(info);
}
Aggregations