コード例 #1
0
 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()});
 }
コード例 #2
0
 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()});
   }
 }
コード例 #3
0
 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()});
 }
コード例 #4
0
 @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);
   }
 }
コード例 #5
0
 @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();
   }
 }
コード例 #6
0
 @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);
   }
 }
コード例 #7
0
 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);
 }
コード例 #8
0
 @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);
   }
 }