@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 void removeDownload(DownloadInfo downloadInfo) throws DbException {
   HttpHandler<File> handler = downloadInfo.getHandler();
   if (handler != null && !handler.isCancelled()) {
     handler.cancel();
   }
   downloadInfoList.remove(downloadInfo);
   db.delete(downloadInfo);
 }
 public void backupDownloadInfoList() throws DbException {
   for (DownloadInfo downloadInfo : downloadInfoList) {
     HttpHandler<File> handler = downloadInfo.getHandler();
     if (handler != null) {
       downloadInfo.setState(handler.getState());
     }
   }
   db.saveOrUpdateAll(downloadInfoList);
 }
 public void stopDownload(DownloadInfo downloadInfo) throws DbException {
   HttpHandler<File> handler = downloadInfo.getHandler();
   if (handler != null && !handler.isCancelled()) {
     handler.cancel();
   } else {
     downloadInfo.setState(HttpHandler.State.CANCELLED);
   }
   db.saveOrUpdate(downloadInfo);
 }
 public void stopDownload(DownloadInfo downloadInfo) throws DbException {
   HttpHandler<File> handler = downloadInfo.getHandler();
   if (handler != null && !handler.isStopped()) {
     handler.stop();
   } else {
     downloadInfo.setState(HttpHandler.State.STOPPED);
   }
   db.saveOrUpdate(downloadInfo);
 }
 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);
   }
 }
 @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);
   }
 }
 @Override
 public void onCancelled() {
   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.onCancelled();
   }
 }
 @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);
   }
 }
 @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);
   try {
     db.saveOrUpdate(downloadInfo);
   } catch (DbException e) {
     LogUtils.e(e.getMessage(), e);
   }
   if (baseCallBack != null) {
     baseCallBack.onLoading(total, current, isUploading);
   }
 }