Created
March 25, 2013 12:15
-
-
Save duanhong169/5236744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 如果当前存在一致的任务,返回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