FileDocCategorySizeDatePackage
DismissViewButton.javaAPI DocAndroid 5.1 API4957Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar

DismissViewButton

public class DismissViewButton extends android.widget.Button

Fields Summary
private android.graphics.drawable.AnimatedVectorDrawable
mAnimatedDismissDrawable
private final android.graphics.drawable.Drawable
mStaticDismissDrawable
private android.graphics.drawable.Drawable
mActiveDrawable
Constructors Summary
public DismissViewButton(android.content.Context context)

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

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

        this(context, attrs, defStyleAttr, 0);
    
public DismissViewButton(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);
        mAnimatedDismissDrawable = (AnimatedVectorDrawable) getContext().getResources().getDrawable(
                R.drawable.dismiss_all_shape_animation).mutate();
        mAnimatedDismissDrawable.setCallback(this);
        mAnimatedDismissDrawable.setBounds(0,
                0,
                mAnimatedDismissDrawable.getIntrinsicWidth(),
                mAnimatedDismissDrawable.getIntrinsicHeight());
        mStaticDismissDrawable = getContext().getResources().getDrawable(
                R.drawable.dismiss_all_shape);
        mStaticDismissDrawable.setBounds(0,
                0,
                mStaticDismissDrawable.getIntrinsicWidth(),
                mStaticDismissDrawable.getIntrinsicHeight());
        mStaticDismissDrawable.setCallback(this);
        mActiveDrawable = mStaticDismissDrawable;
    
Methods Summary
public voidgetDrawingRect(android.graphics.Rect outRect)
This method returns the drawing rect for the view which is different from the regular drawing rect, since we layout all children in the {@link NotificationStackScrollLayout} at position 0 and usually the translation is neglected. The standard implementation doesn't account for translation.

param
outRect The (scrolled) drawing bounds of the view.

        super.getDrawingRect(outRect);
        float translationX = ((ViewGroup) mParent).getTranslationX();
        float translationY = ((ViewGroup) mParent).getTranslationY();
        outRect.left += translationX;
        outRect.right += translationX;
        outRect.top += translationY;
        outRect.bottom += translationY;
    
public booleanhasOverlappingRendering()

        return false;
    
public booleanisButtonStatic()

return
Whether the button is currently static and not being animated.

        return mActiveDrawable == mStaticDismissDrawable;
    
protected voidonDraw(android.graphics.Canvas canvas)

        super.onDraw(canvas);
        canvas.save();
        int drawableHeight = mActiveDrawable.getBounds().height();
        boolean isRtl = (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
        int dx = isRtl ? getWidth() / 2 + drawableHeight / 2 : getWidth() / 2 - drawableHeight / 2;
        canvas.translate(dx, getHeight() / 2.0f + drawableHeight /
                2.0f);
        canvas.scale(isRtl ? -1.0f : 1.0f, -1.0f);
        mActiveDrawable.draw(canvas);
        canvas.restore();
    
public booleanperformClick()

        if (!mAnimatedDismissDrawable.isRunning()) {
            mActiveDrawable = mAnimatedDismissDrawable;
            mAnimatedDismissDrawable.start();
        }
        return super.performClick();
    
public voidshowButton()

        mActiveDrawable = mStaticDismissDrawable;
        invalidate();
    
protected booleanverifyDrawable(android.graphics.drawable.Drawable who)

        return super.verifyDrawable(who)
                || who == mAnimatedDismissDrawable
                || who == mStaticDismissDrawable;