Ejemplo n.º 1
0
  public MsgDetailReadWorker(WeiboDetailImageView view, MessageBean msg) {
    this.view = view;
    this.pb = this.view.getProgressBar();
    this.msg = msg;
    this.retry = view.getRetryButton();
    retry.setVisibility(View.INVISIBLE);

    oriPath =
        FileManager.getFilePathFromUrl(msg.getOriginal_pic(), FileLocationMethod.picture_large);

    if (ImageUtility.isThisBitmapCanRead(oriPath)
        && TaskCache.isThisUrlTaskFinished(msg.getOriginal_pic())) {

      onPostExecute(oriPath);
      cancel(true);
      return;
    }

    middlePath =
        FileManager.getFilePathFromUrl(msg.getBmiddle_pic(), FileLocationMethod.picture_bmiddle);

    if (ImageUtility.isThisBitmapCanRead(middlePath)
        && TaskCache.isThisUrlTaskFinished(msg.getBmiddle_pic())) {
      onPostExecute(middlePath);
      cancel(true);
      return;
    }

    pb.setVisibility(View.VISIBLE);
    pb.setIndeterminate(true);
  }
Ejemplo n.º 2
0
  @Override
  protected String doInBackground(Void... arg) {
    if (isCancelled()) {
      return null;
    }

    if (Utility.isWifi(GlobalContext.getInstance())) {
      boolean result =
          TaskCache.waitForPictureDownload(
              msg.getOriginal_pic(), downloadListener, oriPath, FileLocationMethod.picture_large);
      return result ? oriPath : null;
    } else {
      boolean result =
          TaskCache.waitForPictureDownload(
              msg.getBmiddle_pic(),
              downloadListener,
              middlePath,
              FileLocationMethod.picture_bmiddle);
      return result ? middlePath : null;
    }
  }