public void resumeDownload(DownloadInfo downloadInfo, final RequestCallBack<File> callback) throws Exception { HttpUtils http = new HttpUtils(); // http.configRequestThreadPoolSize(maxDownloadThread); HttpHandler<File> handler = http.download( downloadInfo.getDownloadUrl(), downloadInfo.getFileSavePath(), downloadInfo.isAutoResume(), downloadInfo.isAutoRename(), new ManagerCallBack(downloadInfo, callback)); downloadInfo.setHandler(handler); downloadInfo.setState(handler.getState()); Log.e("TAG", "--resumeDownload downloadInfo=" + downloadInfo.toString()); infoImpl.saveOrUpdate( downloadInfo, "downloadUrl=?", new String[] {downloadInfo.getDownloadUrl()}); }
public void backupDownloadInfoList() throws Exception { for (DownloadInfo downloadInfo : downloadInfoList) { HttpHandler<File> handler = downloadInfo.getHandler(); if (handler != null) { downloadInfo.setState(handler.getState()); } infoImpl.saveOrUpdate( downloadInfo, "downloadUrl=?", new String[] {downloadInfo.getDownloadUrl()}); } }
public void stopDownload(DownloadInfo downloadInfo) throws Exception { HttpHandler<File> handler = downloadInfo.getHandler(); if (handler != null && !handler.isCancelled()) { handler.cancel(); } else { downloadInfo.setState(HttpHandler.State.CANCELLED); } infoImpl.saveOrUpdate( downloadInfo, "downloadUrl=?", new String[] {downloadInfo.getDownloadUrl()}); }
@Override public void onFailure(HttpException error, String msg) { HttpHandler<File> handler = downloadInfo.getHandler(); if (handler != null) { downloadInfo.setState(handler.getState()); } infoImpl.saveOrUpdate( downloadInfo, "downloadUrl=?", new String[] {downloadInfo.getDownloadUrl()}); if (baseCallBack != null) { baseCallBack.onFailure(error, msg); } }
@Override public void onCancelled() { HttpHandler<File> handler = downloadInfo.getHandler(); if (handler != null) { downloadInfo.setState(handler.getState()); } infoImpl.saveOrUpdate( downloadInfo, "downloadUrl=?", new String[] {downloadInfo.getDownloadUrl()}); if (baseCallBack != null) { baseCallBack.onCancelled(); } }
@Override public void onSuccess(ResponseInfo<File> responseInfo) { HttpHandler<File> handler = downloadInfo.getHandler(); if (handler != null) { downloadInfo.setState(handler.getState()); } Log.e("TAG", "*******downloadInfo.state=" + downloadInfo.getState()); infoImpl.saveOrUpdate( downloadInfo, "downloadUrl=?", new String[] {downloadInfo.getDownloadUrl()}); if (baseCallBack != null) { baseCallBack.onSuccess(responseInfo); } }
public void resumeDownload(DownloadInfo downloadInfo, final RequestCallBack<File> callback) throws DbException { HttpUtils http = new HttpUtils(); http.configRequestThreadPoolSize(maxDownloadThread); HttpHandler<File> handler = http.download( downloadInfo.getDownloadUrl(), downloadInfo.getFileSavePath(), downloadInfo.isAutoResume(), new ManagerCallBack(downloadInfo, callback)); downloadInfo.setHandler(handler); downloadInfo.setState(handler.getState()); db.saveOrUpdate(downloadInfo); }
@Override public void onLoading(long total, long current, boolean isUploading) { HttpHandler<File> handler = downloadInfo.getHandler(); if (handler != null) { downloadInfo.setState(handler.getState()); } downloadInfo.setFileLength(total); downloadInfo.setProgress(current); infoImpl.saveOrUpdate( downloadInfo, "downloadUrl=?", new String[] {downloadInfo.getDownloadUrl()}); if (baseCallBack != null) { baseCallBack.onLoading(total, current, isUploading); } }