FileDocCategorySizeDatePackage
BitmapDrawableImageView.javaAPI DocAndroid 5.1 API4348Thu Mar 12 22:22:50 GMT 2015com.android.bitmap.view

BitmapDrawableImageView

public class BitmapDrawableImageView extends android.widget.ImageView
A helpful ImageView replacement that can generally be used in lieu of ImageView. BitmapDrawableImageView has logic to unbind its BasicBitmapDrawable when it is detached from the window.

Fields Summary
private static final boolean
HAS_TRANSIENT_STATE_SUPPORTED
private static final boolean
TEMPORARY
private static final boolean
PERMANENT
private com.android.bitmap.drawable.BasicBitmapDrawable
mDrawable
private boolean
mAttachedToWindow
Constructors Summary
public BitmapDrawableImageView(android.content.Context context)


        
        this(context, null);
    
public BitmapDrawableImageView(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public BitmapDrawableImageView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);
    
Methods Summary
public EgetTypedDrawable()
Get the source drawable for this BitmapDrawableImageView.

return
The source drawable casted to the given type, or null if the type does not match.

        try {
            return (E) mDrawable;
        } catch (Exception ignored) {
            return null;
        }
    
protected voidonAttachedToWindow()

        super.onAttachedToWindow();
        mAttachedToWindow = true;
        if (mDrawable != null && mDrawable.getKey() == null
              && mDrawable.getPreviousKey() != null) {
            mDrawable.bind(mDrawable.getPreviousKey());
        }
    
protected voidonDetachedFromWindow()

        super.onDetachedFromWindow();
        mAttachedToWindow = false;
        if (HAS_TRANSIENT_STATE_SUPPORTED && !hasTransientState()) {
            unbindDrawable(TEMPORARY);
        }
    
public voidsetHasTransientState(boolean hasTransientState)

        super.setHasTransientState(hasTransientState);
        if (!hasTransientState && !mAttachedToWindow) {
            unbindDrawable(TEMPORARY);
        }
    
public voidsetImageBitmap(android.graphics.Bitmap bm)

        super.setImageBitmap(bm);
        unbindDrawable();
        mDrawable = null;
    
public voidsetImageDrawable(android.graphics.drawable.Drawable drawable)

        super.setImageDrawable(drawable);
        unbindDrawable();
        mDrawable = null;
    
public voidsetImageResource(int resId)

        super.setImageResource(resId);
        unbindDrawable();
        mDrawable = null;
    
public voidsetImageURI(android.net.Uri uri)

        super.setImageURI(uri);
        unbindDrawable();
        mDrawable = null;
    
public voidsetTypedDrawable(E drawable)
Set the given drawable as the source for this BitmapDrawableImageView.

param
drawable The source drawable.

        super.setImageDrawable(drawable);
        unbindDrawable();
        mDrawable = drawable;
    
private voidunbindDrawable()

        unbindDrawable(PERMANENT);
    
private voidunbindDrawable(boolean temporary)

        if (mDrawable != null) {
            mDrawable.unbind(temporary);
        }