diff options
author | Eric Kuck <eric@bluelinelabs.com> | 2018-07-12 19:10:35 -0500 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-13 03:46:23 +0200 |
commit | 67ea8b2936343526ff0b3f476c515f0e11dbb272 (patch) | |
tree | 84f904d66f6111a7d8f897164eb236bc62199cae /app/src/main/java/com/wireguard/android/widget/SlashDrawable.java | |
parent | fbaa4d9ab1b59ba4610fe273743872f35e7e9091 (diff) |
global: Add nullity annotations
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/widget/SlashDrawable.java')
-rw-r--r-- | app/src/main/java/com/wireguard/android/widget/SlashDrawable.java | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/app/src/main/java/com/wireguard/android/widget/SlashDrawable.java b/app/src/main/java/com/wireguard/android/widget/SlashDrawable.java index 64fe7f73..53530e0a 100644 --- a/app/src/main/java/com/wireguard/android/widget/SlashDrawable.java +++ b/app/src/main/java/com/wireguard/android/widget/SlashDrawable.java @@ -25,11 +25,9 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.ColorInt; import android.support.annotation.IntRange; -import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.FloatProperty; - @TargetApi(Build.VERSION_CODES.N) public class SlashDrawable extends Drawable { @@ -53,26 +51,24 @@ public class SlashDrawable extends Drawable { // Draw the slash washington-monument style; rotate to no-u-turn style private static final float DEFAULT_ROTATION = -45f; - private Drawable mDrawable; + private final Drawable mDrawable; private final RectF mSlashRect = new RectF(0, 0, 0, 0); private float mRotation; private boolean mSlashed; - private Mode mTintMode; - private ColorStateList mTintList; private boolean mAnimationEnabled = true; public SlashDrawable(final Drawable d) { - setDrawable(d); + mDrawable = d; } @Override public int getIntrinsicHeight() { - return mDrawable != null ? mDrawable.getIntrinsicHeight(): 0; + return mDrawable.getIntrinsicHeight(); } @Override public int getIntrinsicWidth() { - return mDrawable != null ? mDrawable.getIntrinsicWidth(): 0; + return mDrawable.getIntrinsicWidth(); } @Override @@ -81,17 +77,6 @@ public class SlashDrawable extends Drawable { mDrawable.setBounds(bounds); } - public void setDrawable(final Drawable d) { - mDrawable = d; - mDrawable.setCallback(getCallback()); - mDrawable.setBounds(getBounds()); - if (mTintMode != null) - mDrawable.setTintMode(mTintMode); - if (mTintList != null) - mDrawable.setTintList(mTintList); - invalidateSelf(); - } - public void setRotation(final float rotation) { if (mRotation == rotation) return; @@ -139,7 +124,7 @@ public class SlashDrawable extends Drawable { @SuppressWarnings("deprecation") @Override - public void draw(@NonNull final Canvas canvas) { + public void draw(final Canvas canvas) { canvas.save(); final Matrix m = new Matrix(); final int width = getBounds().width(); @@ -201,7 +186,6 @@ public class SlashDrawable extends Drawable { @Override public void setTintList(@Nullable final ColorStateList tint) { - mTintList = tint; super.setTintList(tint); setDrawableTintList(tint); mPaint.setColor(tint == null ? 0 : tint.getDefaultColor()); @@ -213,8 +197,7 @@ public class SlashDrawable extends Drawable { } @Override - public void setTintMode(@NonNull final Mode tintMode) { - mTintMode = tintMode; + public void setTintMode(final Mode tintMode) { super.setTintMode(tintMode); mDrawable.setTintMode(tintMode); } |