@Override public void onSuccess(ResponseInfo<File> responseInfo) { if (downloadInfo.getFileLength() != downloadInfo.getProgress()) { // 不一致 返回 return; } if (downloadInfo.getAutoRenameTmp()) { // 成功后改名 File tarFile = new File(downloadInfo.getFileTmpPath()); if (tarFile.exists()) { File newFile = new File(downloadInfo.getFileSavePath()); tarFile.renameTo(newFile); } } LogUtils.d(downloadInfo.getPkg() + " onSuccess"); HttpHandler<File> handler = downloadInfo.getHandler(); if (handler != null) { downloadInfo.setState(handler.getState()); } try { db.saveOrUpdate(downloadInfo); } catch (DbException e) { LogUtils.e(e.getMessage(), e); } if (baseCallBack != null) { baseCallBack.onSuccess(responseInfo); } }
public DownloadInfo getDownloadInfo(String pkg, int versionCode) { for (DownloadInfo info : downloadInfoList) { if (pkg.equals(info.getPkg().equals(pkg))) { return info; } } return null; }
@Override public void onFailure(HttpException error, String msg) { LogUtils.d(downloadInfo.getPkg() + " onFailure"); HttpHandler<File> handler = downloadInfo.getHandler(); if (handler != null) { downloadInfo.setState(handler.getState()); } try { db.saveOrUpdate(downloadInfo); } catch (DbException e) { LogUtils.e(e.getMessage(), e); } if (baseCallBack != null) { baseCallBack.onFailure(error, msg); } }