use of com.benmu.framework.http.okhttp.callback.FileCallBack in project WeexErosFramework by bmfe.
the class MultipleFileDownloader method execute.
public void execute() {
if (mList == null)
return;
AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
for (final String url : mList) {
final String fileName = createFileName(url);
axiosManager.download(url, new FileCallBack(mPath, fileName) {
@Override
public void onError(Call call, Exception e, int id) {
mSize++;
Log.e("url", "error" + url);
erros.add(new FileItem(new File(mPath, fileName).getAbsolutePath(), fileName));
postResult(mSize);
}
@Override
public void onResponse(File response, int id) {
mSize++;
Log.e("url", url);
paths.add(new FileItem(new File(mPath, fileName).getAbsolutePath(), fileName));
postResult(mSize);
}
});
}
}
use of com.benmu.framework.http.okhttp.callback.FileCallBack in project WeexErosFramework by bmfe.
the class VersionChecker method download.
/**
* 下载包
*/
public void download(final VersionBean version, final boolean complete) {
try {
if (version == null) {
mCurrentStatus = Constant.Version.SLEEP;
return;
}
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
versionManager.downloadBundle(version.data.path, new FileCallBack(FileManager.getTempBundleDir(mContext).getAbsolutePath(), version.data.diff ? FileManager.PATCH_NAME : FileManager.TEMP_BUNDLE_NAME) {
@Override
public void onError(Call call, Exception e, int id) {
Log.e(TAG, "下载插分包出错");
if (!complete) {
downloadCompleteZip();
} else {
mCurrentStatus = Constant.Version.SLEEP;
}
}
@Override
public void onResponse(File response, int id) {
Log.e("version", "下载成功" + response.getAbsolutePath());
if (version.data.diff) {
bsPatch();
} else {
File download = new File(FileManager.getTempBundleDir(mContext), FileManager.TEMP_BUNDLE_NAME);
if (checkZipValidate(download)) {
RenameDeleteFile();
// 更改本地jsversion
SharePreferenceUtil.setDownLoadVersion(mContext, ManagerFactory.getManagerService(ParseManager.class).toJsonString(newVersion));
newVersion = null;
mCurrentStatus = Constant.Version.SLEEP;
} else {
L.e(TAG, "更新包md5校验失败,更新失败");
FileManager.deleteFile(new File(FileManager.getTempBundleDir(mContext), FileManager.TEMP_BUNDLE_NAME));
newVersion = null;
mCurrentStatus = Constant.Version.SLEEP;
}
}
}
});
} catch (Exception e) {
mCurrentStatus = Constant.Version.SLEEP;
e.printStackTrace();
}
}
Aggregations