Skip to content

Instantly share code, notes, and snippets.

@duanhong169
Created March 25, 2013 12:15
Show Gist options
  • Save duanhong169/5236744 to your computer and use it in GitHub Desktop.
Save duanhong169/5236744 to your computer and use it in GitHub Desktop.
/**
* 如果当前存在一致的任务,返回false,代表不需要新建任务,否则返回true
*/
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);
if (BuildConfig.DEBUG) {
Log.d(TAG, "cancelPotentialWork - cancelled work for " + data);
}
} else {
// The same work is already in progress.
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment