Skip to content

Instantly share code, notes, and snippets.

@jinqian
Created July 8, 2013 15:20
Show Gist options
  • Select an option

  • Save jinqian/5949760 to your computer and use it in GitHub Desktop.

Select an option

Save jinqian/5949760 to your computer and use it in GitHub Desktop.
/**
* Common view components such as ListView and GridView recycle child views
* as users scrolls. If each child view triggers an load task, there is no
* guarantee when it completes, the associated view has not already been
* recycled for use in another child view, either for the order in which
* asynchronous tasks are started is the order that they complete.
*
* This custom Drawable that will be attached to the imageView while the
* work is in progress. Contains a reference to the actual loading image,
* a.k.a the uid of the image being loading.
*
* so that it can be stopped if a new binding is required, and makes sure
* that only the last started worker process can bind its result,
* independently of the finish order.
*/
static class AsyncDrawable extends BitmapDrawable {
private String key;
public AsyncDrawable(Resources res, Bitmap bitmap, String key) {
super(res, bitmap);
this.key = key;
}
public String getLoadTaskKey() {
return this.key;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment