@Test @SuppressWarnings("Range") public void setAlpha() { badgeDrawable.setAlpha(0); assertThat(badgeDrawable.getAlpha(), is(0)); badgeDrawable.assertInvalidated(); badgeDrawable.setAlpha(1); assertThat(badgeDrawable.getAlpha(), is(1)); badgeDrawable.assertInvalidated(); badgeDrawable.setAlpha(255); assertThat(badgeDrawable.getAlpha(), is(255)); badgeDrawable.assertInvalidated(); badgeDrawable.setAlpha(-1); assertThat(badgeDrawable.getAlpha(), is(0)); badgeDrawable.assertInvalidated(); badgeDrawable.setAlpha(256); assertThat(badgeDrawable.getAlpha(), is(255)); badgeDrawable.assertInvalidated(); badgeDrawable.setAlpha(512); assertThat(badgeDrawable.getAlpha(), is(255)); badgeDrawable.assertNotInvalidated(); }
@Override public void setAlpha(@IntRange(from = 0, to = 255) int alpha) { if (alpha > 255) { alpha = 255; } else if (alpha < 0) { alpha = 0; } if (this.alpha != alpha) { this.alpha = alpha; invalidateSelf(); } }
BadgeDrawable extends Drawable { @Override public void setAlpha(@IntRange(from = 0, to = 255) int alpha) { if (alpha > 255) { alpha = 255; } else if (alpha < 0) { alpha = 0; } if (this.alpha != alpha) { this.alpha = alpha; invalidateSelf(); } } }
BadgeDrawable extends Drawable { @Override public void setAlpha(@IntRange(from = 0, to = 255) int alpha) { if (alpha > 255) { alpha = 255; } else if (alpha < 0) { alpha = 0; } if (this.alpha != alpha) { this.alpha = alpha; invalidateSelf(); } }  }
BadgeDrawable extends Drawable { @Override public void setAlpha(@IntRange(from = 0, to = 255) int alpha) { if (alpha > 255) { alpha = 255; } else if (alpha < 0) { alpha = 0; } if (this.alpha != alpha) { this.alpha = alpha; invalidateSelf(); } }  @Override void setAlpha(@IntRange(from = 0, to = 255) int alpha); @Override int getAlpha(); @Override void setColorFilter(@Nullable ColorFilter colorFilter); @Override @Nullable ColorFilter getColorFilter(); @Override int getOpacity(); @Nullable @Override ConstantState getConstantState(); }
BadgeDrawable extends Drawable { @Override public void setAlpha(@IntRange(from = 0, to = 255) int alpha) { if (alpha > 255) { alpha = 255; } else if (alpha < 0) { alpha = 0; } if (this.alpha != alpha) { this.alpha = alpha; invalidateSelf(); } }  @Override void setAlpha(@IntRange(from = 0, to = 255) int alpha); @Override int getAlpha(); @Override void setColorFilter(@Nullable ColorFilter colorFilter); @Override @Nullable ColorFilter getColorFilter(); @Override int getOpacity(); @Nullable @Override ConstantState getConstantState();  }