FileDocCategorySizeDatePackage
DrawableContainer.javaAPI DocAndroid 1.5 API15296Wed May 06 22:42:00 BST 2009android.graphics.drawable

DrawableContainer

public class DrawableContainer extends Drawable implements Drawable.Callback

Fields Summary
private DrawableContainerState
mDrawableContainerState
private Drawable
mCurrDrawable
private int
mAlpha
private ColorFilter
mColorFilter
private boolean
mDither
private int
mCurIndex
private boolean
mMutated
Constructors Summary
Methods Summary
public voiddraw(Canvas canvas)


    // overrides from Drawable

    
        
        if (mCurrDrawable != null) {
            mCurrDrawable.draw(canvas);
        }
    
public intgetChangingConfigurations()

        return super.getChangingConfigurations()
                | mDrawableContainerState.mChangingConfigurations
                | mDrawableContainerState.mChildrenChangingConfigurations;
    
public ConstantStategetConstantState()

        if (mDrawableContainerState.canConstantState()) {
            mDrawableContainerState.mChangingConfigurations = super.getChangingConfigurations();
            return mDrawableContainerState;
        }
        return null;
    
public DrawablegetCurrent()

        return mCurrDrawable;
    
public intgetIntrinsicHeight()

        if (mDrawableContainerState.isConstantSize()) {
            return mDrawableContainerState.getConstantHeight();
        }
        return mCurrDrawable != null ? mCurrDrawable.getIntrinsicHeight() : -1;
    
public intgetIntrinsicWidth()

        if (mDrawableContainerState.isConstantSize()) {
            return mDrawableContainerState.getConstantWidth();
        }
        return mCurrDrawable != null ? mCurrDrawable.getIntrinsicWidth() : -1;
    
public intgetMinimumHeight()

        if (mDrawableContainerState.isConstantSize()) {
            return mDrawableContainerState.getConstantMinimumHeight();
        }
        return mCurrDrawable != null ? mCurrDrawable.getMinimumHeight() : 0;
    
public intgetMinimumWidth()

        if (mDrawableContainerState.isConstantSize()) {
            return mDrawableContainerState.getConstantMinimumWidth();
        }
        return mCurrDrawable != null ? mCurrDrawable.getMinimumWidth() : 0;
    
public intgetOpacity()

        return mDrawableContainerState.getOpacity();
    
public booleangetPadding(Rect padding)

        final Rect r = mDrawableContainerState.getConstantPadding();
        if (r != null) {
            padding.set(r);
            return true;
        }
        if (mCurrDrawable != null) {
            return mCurrDrawable.getPadding(padding);
        } else {
            return super.getPadding(padding);
        }
    
public voidinvalidateDrawable(Drawable who)

        if (who == mCurrDrawable && mCallback != null) {
            mCallback.invalidateDrawable(this);
        }
    
public booleanisStateful()

        return mDrawableContainerState.isStateful();
    
public Drawablemutate()

        if (!mMutated && super.mutate() == this) {
            for (Drawable child : mDrawableContainerState.mDrawables) {
                child.mutate();
            }
            mMutated = true;
        }
        return this;
    
protected voidonBoundsChange(Rect bounds)

        if (mCurrDrawable != null) {
            mCurrDrawable.setBounds(bounds);
        }
    
protected booleanonLevelChange(int level)

        if (mCurrDrawable != null) {
            return mCurrDrawable.setLevel(level);
        }
        return false;
    
protected booleanonStateChange(int[] state)

        if (mCurrDrawable != null) {
            return mCurrDrawable.setState(state);
        }
        return false;
    
public voidscheduleDrawable(Drawable who, java.lang.Runnable what, long when)

        if (who == mCurrDrawable && mCallback != null) {
            mCallback.scheduleDrawable(this, what, when);
        }
    
public booleanselectDrawable(int idx)

        if (idx == mCurIndex) {
            return false;
        }
        if (idx >= 0 && idx < mDrawableContainerState.mNumChildren) {
            Drawable d = mDrawableContainerState.mDrawables[idx];
            if (mCurrDrawable != null) {
                mCurrDrawable.setVisible(false, false);
            }
            mCurrDrawable = d;
            mCurIndex = idx;
            if (d != null) {
                d.setVisible(isVisible(), true);
                d.setAlpha(mAlpha);
                d.setDither(mDither);
                d.setColorFilter(mColorFilter);
                d.setState(getState());
                d.setLevel(getLevel());
                d.setBounds(getBounds());
            }
        } else {
            if (mCurrDrawable != null) {
                mCurrDrawable.setVisible(false, false);
            }
            mCurrDrawable = null;
            mCurIndex = -1;
        }
        invalidateSelf();
        return true;
    
public voidsetAlpha(int alpha)

        if (mAlpha != alpha) {
            mAlpha = alpha;
            if (mCurrDrawable != null) {
                mCurrDrawable.setAlpha(alpha);
            }
        }
    
public voidsetColorFilter(ColorFilter cf)

        if (mColorFilter != cf) {
            mColorFilter = cf;
            if (mCurrDrawable != null) {
                mCurrDrawable.setColorFilter(cf);
            }
        }
    
protected voidsetConstantState(android.graphics.drawable.DrawableContainer$DrawableContainerState state)

        mDrawableContainerState = state;
    
public voidsetDither(boolean dither)

        if (mDither != dither) {
            mDither = dither;
            if (mCurrDrawable != null) {
                mCurrDrawable.setDither(mDither);
            }
        }
    
public booleansetVisible(boolean visible, boolean restart)

        boolean changed = super.setVisible(visible, restart);
        if (mCurrDrawable != null) {
            mCurrDrawable.setVisible(visible, restart);
        }
        return changed;
    
public voidunscheduleDrawable(Drawable who, java.lang.Runnable what)

        if (who == mCurrDrawable && mCallback != null) {
            mCallback.unscheduleDrawable(this, what);
        }