public void downloadApkFile(
     String url,
     String fileName,
     String pkg,
     int versionCode,
     String savePath,
     boolean autoResume,
     final RequestCallBack<File> callback)
     throws DbException {
   if (checkDownloaded(pkg, versionCode, savePath)) {
     PackageUtils.installApp(mContext, savePath);
     return;
   }
   String tmpApkPath = savePath + getMD5ApkTmpName(pkg, versionCode);
   String apkPath = savePath + getMD5ApkName(pkg, versionCode);
   final DownloadInfo downloadInfo = new DownloadInfo();
   downloadInfo.setDownloadUrl(url);
   downloadInfo.setAutoResume(autoResume);
   downloadInfo.setFileName(fileName);
   downloadInfo.setFileTmpPath(tmpApkPath);
   downloadInfo.setFileSavePath(apkPath);
   downloadInfo.setPkg(pkg);
   downloadInfo.setVersionCode(versionCode);
   downloadInfo.setAutoRenameTmp(true);
   HttpUtils http = new HttpUtils();
   http.configRequestThreadPoolSize(maxDownloadThread);
   HttpHandler<File> handler =
       http.download(url, tmpApkPath, autoResume, new ManagerCallBack(downloadInfo, callback));
   downloadInfo.setHandler(handler);
   downloadInfo.setState(handler.getState());
   downloadInfoList.add(downloadInfo);
   db.saveBindingId(downloadInfo);
 }
Esempio n. 2
0
 public void addNewDownload(
     String url,
     String fileName,
     String target,
     boolean autoResume,
     boolean autoRename,
     final RequestCallBack<File> callback)
     throws Exception {
   final DownloadInfo downloadInfo = new DownloadInfo();
   downloadInfo.setDownloadUrl(url);
   downloadInfo.setAutoRename(autoRename);
   downloadInfo.setAutoResume(autoResume);
   downloadInfo.setFileName(fileName);
   downloadInfo.setFileSavePath(target);
   downloadInfo.setId(mCount.getAndIncrement());
   HttpUtils http = new HttpUtils();
   //        http.configRequestThreadPoolSize(maxDownloadThread);
   HttpHandler<File> handler =
       http.download(
           url, target, autoResume, autoRename, new ManagerCallBack(downloadInfo, callback));
   downloadInfo.setHandler(handler);
   downloadInfo.setState(handler.getState());
   downloadInfoList.add(downloadInfo);
   infoImpl.insert(downloadInfo);
 }
Esempio n. 3
0
 public void addNewDownload(DownloadInfo info, final RequestCallBack<File> callback) {
   info.setId(mCount.getAndIncrement());
   HttpUtils http = new HttpUtils();
   HttpHandler<File> handler = http.download(info, new ManagerCallBack(info, callback));
   info.setHandler(handler);
   info.setState(handler.getState());
   downloadInfoList.add(info);
   infoImpl.insert(info, false);
 }
 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);
 }
Esempio n. 5
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()});
 }