Skip to content

Instantly share code, notes, and snippets.

@jfsurban
Created May 15, 2012 08:59
Show Gist options
  • Save jfsurban/2700204 to your computer and use it in GitHub Desktop.
Save jfsurban/2700204 to your computer and use it in GitHub Desktop.
subclass of ImageView which nulls the drawable references and calls gc when the imageview is detached from the window - http://bit.ly/L5OWwu
public class SingleShotImageView extends ImageView {
public SingleShotImageView(Context context) {
super(context);
}
public SingleShotImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SingleShotImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onDetachedFromWindow () {
setImageDrawable(null);
setBackgroundDrawable(null);
System.gc();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment