DismissViewButtonpublic 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 void | getDrawingRect(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.
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 boolean | hasOverlappingRendering()
return false;
| public boolean | isButtonStatic()
return mActiveDrawable == mStaticDismissDrawable;
| protected void | onDraw(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 boolean | performClick()
if (!mAnimatedDismissDrawable.isRunning()) {
mActiveDrawable = mAnimatedDismissDrawable;
mAnimatedDismissDrawable.start();
}
return super.performClick();
| public void | showButton()
mActiveDrawable = mStaticDismissDrawable;
invalidate();
| protected boolean | verifyDrawable(android.graphics.drawable.Drawable who)
return super.verifyDrawable(who)
|| who == mAnimatedDismissDrawable
|| who == mStaticDismissDrawable;
|
|