コード例 #1
0
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.installApk) {
      if (isDownloading) {
        // cancel downloading
        cancelDownloading();
      } else {
        isDownloading = true;
        DownloadTask task = new DownloadTask();
        task.setTitle(mAppInfoForManage.getLabel().toString());
        task.setId(mAppInfoForManage.getAppId());
        if (mAppInfoForManage.getIcon() != null) {
          Bitmap bitmap = ((BitmapDrawable) mAppInfoForManage.getIcon()).getBitmap();
          task.setIcon(bitmap);
        }
        task.setPackageName(mAppInfoForManage.getPackageName());
        task.setDownUrl(mAppInfoForManage.getPackagePath());
        task.setTotalSize((int) mAppInfoForManage.getSize());

        if (DownloadService.addDownTask(task)) {
          Intent i = new Intent(DownloadService.UPDATE_DOWN_TASK);
          i.setClass(this, DownloadService.class);
          startService(i);
        }
        mProgressBar.setVisibility(View.VISIBLE);
        mDownloadingText.setVisibility(View.VISIBLE);
        mHandler.sendEmptyMessage(2);
      }
      updateButton();
    }
  }
コード例 #2
0
 private void fillData() {
   if (mAppInfoForManage != null) {
     if (mAppInfoForManage.getIcon() != null) {
       mAppIcon.setImageDrawable(mAppInfoForManage.getIcon());
     } else {
       mAppIcon.setImageDrawable(getPackageManager().getDefaultActivityIcon());
     }
     mAppName.setText(mAppInfoForManage.getLabel());
     mAppVersion.setText(mAppInfoForManage.getVersion());
     String sizeStr = new UnitsConversion().defaultConversion(mAppInfoForManage.getSize());
     String[] size = sizeStr.split(" ");
     if (size.length > 1) {
       mAppSizeNum.setText(size[0]);
       mAppSizeUnit.setText(size[1]);
     }
     mAppDescription.setText(mAppInfoForManage.getDescription());
     if (mAppInfoForManage.getPartnerId() == 0) {
       mScreenshotOne.setVisibility(View.VISIBLE);
       mScreenshotTwo.setVisibility(View.VISIBLE);
       mLoadScreenShotOne = new LoadScreenShot(0);
       mLoadScreenShotTwo = new LoadScreenShot(1);
       mLoadScreenShotOne.start();
       mLoadScreenShotTwo.start();
     } else {
       mScreenshotOne.setVisibility(View.GONE);
       mScreenshotTwo.setVisibility(View.GONE);
     }
   }
 }