Ejemplo n.º 1
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.app_update_all_btn:
        // 全部升级
        if (mBean.uAppList != null) {
          for (UpdateAppBean bean : mBean.uAppList) {
            // 判读是否已安装已下载
            if (FileUtil.isFileExist(DownloadUtil.getCApkFileFromUrl(bean.downloadUrl))) {
              continue;
            }
            if (bean.downloadStatus != DownloadTask.DOWNLOADING
                || bean.downloadStatus != DownloadTask.WAITING) {
              bean.downloadStatus = DownloadTask.WAITING;
              Intent intent = new Intent(IDownloadInterface.DOWNLOAD_REQUEST_ACTION);
              intent.putExtra("command", IDownloadInterface.REQUEST_COMMAND_ADD);
              intent.putExtra("url", bean.downloadUrl);
              intent.putExtra("iconUrl", bean.iconUrl);
              intent.putExtra("name", bean.name);
              intent.putExtra("size", bean.size);
              intent.putExtra("packName", bean.packageName);
              intent.putExtra("appId", bean.id + 0l);
              intent.putExtra("version", bean.version);
              intent.putExtra("page", "应用更新");
              TAApplication.getApplication().sendBroadcast(intent);
            }
          }
          adapter.notifyDataSetChanged();
        }
        break;

      default:
        break;
    }
  }
Ejemplo n.º 2
0
 /** 用下载任务列表更新应用列表的下载状态 */
 private void updateDownloadState(List<UpdateAppBean> list) {
   if (list == null || list.size() <= 0) {
     return;
   }
   Map<String, DownloadTask> map = DownloadTaskRecorder.getInstance().getDownloadTaskList();
   for (UpdateAppBean bean : list) {
     if (map.containsKey(bean.downloadUrl)) {
       DownloadTask task = map.get(bean.downloadUrl);
       bean.downloadStatus = task.state;
       bean.alreadyDownloadPercent = task.alreadyDownloadPercent;
     } else {
       bean.downloadStatus = DownloadTask.NOT_START;
       bean.alreadyDownloadPercent = 0;
     }
   }
 }
Ejemplo n.º 3
0
 @Override
 public void notifyDownloadState(DownloadTask downloadTask) {
   boolean needToUpdate = false;
   if (mBean.uAppList != null && mBean.uAppList.size() > 0) {
     for (UpdateAppBean bean : mBean.uAppList) {
       if (bean.downloadUrl.equals(downloadTask.url)) {
         needToUpdate = true;
         bean.downloadStatus = downloadTask.state;
         bean.alreadyDownloadPercent = downloadTask.alreadyDownloadPercent;
       }
     }
   }
   if (needToUpdate) {
     adapter.update(mBean.uAppList);
   }
 }