/** 取消所有正在下载或等待下载的任务。 */
 public void cancelAllTasks() {
   if (taskCollection != null) {
     for (BitmapWorkerTask task : taskCollection) {
       task.cancel(false);
     }
   }
 }
Пример #2
0
 /**
  * 取消这个imageview所对应的任务
  *
  * @param imageView
  */
 public static void cancelWork(ImageView imageView) {
   final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
   if (bitmapWorkerTask != null) {
     bitmapWorkerTask.cancel(true);
     final Object bitmapData = bitmapWorkerTask.mData;
     Ioc.getIoc().getLogger().d("cancelWork - cancelled work for " + bitmapData);
   }
 }
Пример #3
0
 /**
  * Cancels any pending work attached to the provided ImageView.
  *
  * @param imageView
  */
 public static void cancelWork(ImageView imageView) {
   final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
   if (bitmapWorkerTask != null) {
     bitmapWorkerTask.cancel(true);
     if (BuildConfig.DEBUG) {
       LOGD(TAG, "cancelWork - cancelled work for " + bitmapWorkerTask.data);
     }
   }
 }
Пример #4
0
 /**
  * Cancels any pending work attached to the provided ImageView.
  *
  * @param imageView
  */
 public static void cancelWork(ImageView imageView) {
   final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
   if (bitmapWorkerTask != null) {
     bitmapWorkerTask.cancel(true);
     if (Constants.DEBUG) {
       final Object bitmapData = bitmapWorkerTask.mData;
       Log.d(TAG, "cancelWork - cancelled work for " + bitmapData);
     }
   }
 }
Пример #5
0
 /**
  * Cancels any pending work attached to the provided ImageView.
  *
  * @param imageView
  */
 public static void cancelWork(ImageViewWithProcessIndicator imageView) {
   final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
   if (bitmapWorkerTask != null) {
     bitmapWorkerTask.cancel(true);
     if (BuildConfig.DEBUG) {
       final Object bitmapData = bitmapWorkerTask.data;
       Log.d(TAG, "cancelWork - cancelled work for " + bitmapData);
     }
   }
 }
 /**
  * Returns true if the current work has been canceled or if there was no work in progress on this
  * image view. Returns false if the work in progress deals with the same data. The work is not
  * stopped in that case.
  */
 public static final boolean executePotentialWork(final Object data, final ImageView imageView) {
   final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
   if (bitmapWorkerTask != null) {
     final Object bitmapData = bitmapWorkerTask.mKey;
     if (bitmapData == null || !bitmapData.equals(data)) {
       bitmapWorkerTask.cancel(true);
     } else {
       // The same work is already in progress
       return false;
     }
   }
   return true;
 }
  public static boolean cancelPotentialWork(int data, ImageView imageView) {
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
      final int bitmapData = bitmapWorkerTask.data;
      if (bitmapData != data) {
        bitmapWorkerTask.cancel(true);
      } else {
        return false;
      }
    }
    return true;
  }
Пример #8
0
  public static boolean cancelPotentialWork(Message message, ImageView imageView) {
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
      final Message oldMessage = bitmapWorkerTask.message;
      if (oldMessage == null || message != oldMessage) {
        bitmapWorkerTask.cancel(true);
      } else {
        return false;
      }
    }
    return true;
  }
  public boolean cancelPotentialWork(String filePath, ImageView imageView) {

    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
      final String bitmapFilePath = bitmapWorkerTask.filePath;
      if (bitmapFilePath != null && !bitmapFilePath.equalsIgnoreCase(filePath)) {
        bitmapWorkerTask.cancel(true);
      } else {
        return false;
      }
    }
    return true;
  }
  /**
   * Returns true if the current work has been canceled or if there was no work in progress on this
   * image view. Returns false if the work in progress deals with the same data. The work is not
   * stopped in that case.
   */
  public static boolean cancelPotentialWork(Object data, ImageView imageView) {
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
      final Object bitmapData = bitmapWorkerTask.data;
      if (bitmapData == null || !bitmapData.equals(data)) {
        bitmapWorkerTask.cancel(true);
        LOGV(TAG, "cancelPotentialWork - cancelled work for " + data);
      } else {
        // The same work is already in progress.
        return false;
      }
    }
    return true;
  }
Пример #11
0
  /**
   *
   *
   * <h1>第一步</h1>
   *
   * 根据imageView获取到AsyncDrawable<br>
   *
   * <h1>第二步</h1>
   *
   * 从AsyncDrawable获得BitmapWorkerTask<br>
   *
   * <h1>第三步</h1>
   *
   * 根据BitmapWorkerTask中的url判断当前下载的url和之前是否一样<br>
   * 如果一样则返回false无需再下载<br>
   *
   * <h1>第四步</h1>
   *
   * 如果不一样则说明 当前imageview需要显示的图片和之前图片不一样,取消之前下载进程 返回true
   */
  public static boolean cancelPotentialWork(Object data, ImageView imageView) {
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
      final Object bitmapData = bitmapWorkerTask.mData;
      // 判断当前的Url和之前的url是否一样
      if (bitmapData == null || !bitmapData.equals(data)) {
        bitmapWorkerTask.cancel(true);
        Ioc.getIoc().getLogger().d("cancelPotentialWork - cancelled work for " + data);
      } else {
        return false;
      }
    }
    return true;
  }
Пример #12
0
 public static boolean cancelPotentialWork(int data, ImageView imageView) {
   final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
   if (bitmapWorkerTask != null) {
     final int bitmapData = bitmapWorkerTask.data;
     if (bitmapData == 0 || bitmapData != data) {
       // 新的任务和之前的不同,则取消之前的任务
       bitmapWorkerTask.cancel(true);
     } else {
       // 相同的任务已经在执行中
       return false;
     }
   }
   // 没有任务和此控件关联,或者一个已经存在的已经被取消
   return true;
 }
  /**
   * Returns true if the current work has been canceled or if there was no work in progress on this
   * image view. Returns false if the work in progress deals with the same data. The work is not
   * stopped in that case.
   */
  public static boolean cancelPotentialWork(Object data, ImageView imageView) {
    // BEGIN_INCLUDE(cancel_potential_work)
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
      final Object bitmapData = bitmapWorkerTask.mData;
      if (bitmapData == null || !bitmapData.equals(data)) {
        bitmapWorkerTask.cancel(true);
      } else {
        // The same work is already in progress.
        return false;
      }
    }
    return true;
    // END_INCLUDE(cancel_potential_work)
  }
Пример #14
0
  public static boolean cancelPotentialWork(int data, ImageView imageView) {
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
      final int bitmapData = bitmapWorkerTask.data;
      if (bitmapData != data) {
        // Cancel previous task
        bitmapWorkerTask.cancel(true);
      } else {
        // The same work is already in progress
        return false;
      }
    }
    // No task associated with the ImageView, or an existing task was
    // cancelled
    return true;
  }
  public static boolean cancelPotentialWork(String key, ImageView imageView) {
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
    if (bitmapWorkerTask != null) {
      final String bitmapKey = bitmapWorkerTask.key;
      if (bitmapKey != key) {
        // Cancel previous task
        Savelog.d(TAG, debug, "Canceling task for key:" + key);
        bitmapWorkerTask.cancel(true);
      } else {
        // The same work is already in progress
        return false;
      }
    }

    // No task associated with the ImageView, or an existing task was cancelled
    return true;
  }
Пример #16
0
  /**
   * Returns true if the current work has been canceled or if there was no work in progress on this
   * image view. Returns false if the work in progress deals with the same data. The work is not
   * stopped in that case.
   */
  public static boolean cancelPotentialWork(Object data, ImageViewWithProcessIndicator imageView) {
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
      final Object bitmapData = bitmapWorkerTask.data;
      if (bitmapData == null || !bitmapData.equals(data)) {
        bitmapWorkerTask.cancel(true);
        if (BuildConfig.DEBUG) {
          Log.d(TAG, "cancelPotentialWork - cancelled work for " + data);
        }
      } else {
        // The same work is already in progress.
        return false;
      }
    }
    return true;
  }
 /**
  * Cancels any pending work attached to the provided ImageView.
  *
  * @param imageView
  */
 public static void cancelWork(ImageView imageView) {
   final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
   if (bitmapWorkerTask != null) {
     bitmapWorkerTask.cancel(true);
   }
 }