diff --git a/app/src/main/java/com/hippo/drawable/BatteryDrawable.java b/app/src/main/java/com/hippo/drawable/BatteryDrawable.java index 85ea34ebc..ff229c196 100644 --- a/app/src/main/java/com/hippo/drawable/BatteryDrawable.java +++ b/app/src/main/java/com/hippo/drawable/BatteryDrawable.java @@ -59,6 +59,7 @@ public class BatteryDrawable extends Drawable { } @Override + @SuppressWarnings("SuspiciousNameCombination") protected void onBoundsChange(Rect bounds) { int width = bounds.width(); int height = bounds.height(); @@ -89,8 +90,9 @@ public class BatteryDrawable extends Drawable { */ @Override public void draw(Canvas canvas) { - if (mElect == -1) + if (mElect == -1) { return; + } mElectRect.right = MathUtils.lerp(mStart, mStop, mElect / 100.0f); @@ -152,21 +154,22 @@ public class BatteryDrawable extends Drawable { } private void updatePaint(boolean warn) { - if (warn) + if (warn) { mPaint.setColor(mWarningColor); - else + } else { mPaint.setColor(mColor); + } invalidateSelf(); } @Override public void setAlpha(int alpha) { - // Empty + mPaint.setAlpha(alpha); } @Override public void setColorFilter(ColorFilter cf) { - // Empty + mPaint.setColorFilter(cf); } @Override diff --git a/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java b/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java index dfaba6da5..e7b429bb9 100644 --- a/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java +++ b/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java @@ -38,7 +38,7 @@ public class DrawerArrowDrawable extends Drawable { private final Paint mPaint = new Paint(); - // The angle in degress that the arrow head is inclined at. + // The angle in degrees that the arrow head is inclined at. private static final float ARROW_HEAD_ANGLE = (float) Math.toRadians(45); private final float mBarThickness; // The length of top and bottom bars when they merge into an arrow @@ -61,7 +61,7 @@ public class DrawerArrowDrawable extends Drawable { // The interpolated version of the original progress private float mProgress; // the amount that overlaps w/ bar size when rotation is max - private float mMaxCutForBarSize; + private final float mMaxCutForBarSize; /** * @param context used to get the configuration for the drawable from diff --git a/app/src/main/java/com/hippo/widget/refreshlayout/CircleImageView.java b/app/src/main/java/com/hippo/widget/refreshlayout/CircleImageView.java index 032bd925d..2140b160b 100644 --- a/app/src/main/java/com/hippo/widget/refreshlayout/CircleImageView.java +++ b/app/src/main/java/com/hippo/widget/refreshlayout/CircleImageView.java @@ -16,6 +16,7 @@ package com.hippo.widget.refreshlayout; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; @@ -24,6 +25,8 @@ import android.graphics.RadialGradient; import android.graphics.Shader; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.OvalShape; +import android.support.annotation.ColorRes; +import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewCompat; import android.view.animation.Animation; import android.widget.ImageView; @@ -32,9 +35,8 @@ import android.widget.ImageView; * Private class created to work around issues with AnimationListeners being * called before the animation is actually complete and support shadows on older * platforms. - * - * @hide */ +@SuppressLint("ViewConstructor") class CircleImageView extends ImageView { private static final int KEY_SHADOW_COLOR = 0x1E000000; @@ -48,6 +50,7 @@ class CircleImageView extends ImageView { private Animation.AnimationListener mListener; private int mShadowRadius; + @SuppressWarnings("deprecation") public CircleImageView(Context context, int color, final float radius) { super(context); final float density = getContext().getResources().getDisplayMetrics().density; @@ -113,8 +116,8 @@ class CircleImageView extends ImageView { * * @param colorRes Id of a color resource. */ - public void setBackgroundColorRes(int colorRes) { - setBackgroundColor(getContext().getResources().getColor(colorRes)); + public void setBackgroundColorRes(@ColorRes int colorRes) { + setBackgroundColor(ContextCompat.getColor(getContext(), colorRes)); } @Override @@ -125,9 +128,9 @@ class CircleImageView extends ImageView { } private class OvalShadow extends OvalShape { - private RadialGradient mRadialGradient; - private Paint mShadowPaint; - private int mCircleDiameter; + private final RadialGradient mRadialGradient; + private final Paint mShadowPaint; + private final int mCircleDiameter; public OvalShadow(int shadowRadius, int circleDiameter) { super(); diff --git a/app/src/main/java/com/hippo/widget/refreshlayout/MaterialProgressDrawable.java b/app/src/main/java/com/hippo/widget/refreshlayout/MaterialProgressDrawable.java index f86016db9..b887b0a95 100644 --- a/app/src/main/java/com/hippo/widget/refreshlayout/MaterialProgressDrawable.java +++ b/app/src/main/java/com/hippo/widget/refreshlayout/MaterialProgressDrawable.java @@ -45,8 +45,6 @@ import java.util.ArrayList; /** * Fancy progress indicator for Material theme. - * - * @hide */ class MaterialProgressDrawable extends Drawable implements Animatable { private static final Interpolator LINEAR_INTERPOLATOR = new LinearInterpolator(); @@ -107,8 +105,8 @@ class MaterialProgressDrawable extends Drawable implements Animatable { private static final int ARROW_HEIGHT_LARGE = 6; private static final float MAX_PROGRESS_ARC = .8f; - private Resources mResources; - private View mParent; + private final Resources mResources; + private final View mParent; private Animation mAnimation; private float mRotationCount; private double mWidth; @@ -204,7 +202,7 @@ class MaterialProgressDrawable extends Drawable implements Animatable { * The first color will also be the color of the bar that grows in response * to a user swipe gesture. * - * @param colors + * @param colors the colors for scheme */ public void setColorSchemeColors(int... colors) { mRing.setColors(colors); @@ -235,6 +233,7 @@ class MaterialProgressDrawable extends Drawable implements Animatable { mRing.setAlpha(alpha); } + @Override public int getAlpha() { return mRing.getAlpha(); } @@ -306,22 +305,20 @@ class MaterialProgressDrawable extends Drawable implements Animatable { // Adapted from ArgbEvaluator.java private int evaluateColorChange(float fraction, int startValue, int endValue) { - int startInt = (Integer) startValue; - int startA = (startInt >> 24) & 0xff; - int startR = (startInt >> 16) & 0xff; - int startG = (startInt >> 8) & 0xff; - int startB = startInt & 0xff; + int startA = (startValue >> 24) & 0xff; + int startR = (startValue >> 16) & 0xff; + int startG = (startValue >> 8) & 0xff; + int startB = startValue & 0xff; - int endInt = (Integer) endValue; - int endA = (endInt >> 24) & 0xff; - int endR = (endInt >> 16) & 0xff; - int endG = (endInt >> 8) & 0xff; - int endB = endInt & 0xff; + int endA = (endValue >> 24) & 0xff; + int endR = (endValue >> 16) & 0xff; + int endG = (endValue >> 8) & 0xff; + int endB = endValue & 0xff; - return (int)((startA + (int)(fraction * (endA - startA))) << 24) | - (int)((startR + (int)(fraction * (endR - startR))) << 16) | - (int)((startG + (int)(fraction * (endG - startG))) << 8) | - (int)((startB + (int)(fraction * (endB - startB)))); + return (startA + (int)(fraction * (endA - startA))) << 24 | + (startR + (int)(fraction * (endR - startR))) << 16 | + (startG + (int)(fraction * (endG - startG))) << 8 | + (startB + (int)(fraction * (endB - startB))); } /** diff --git a/app/src/main/java/com/hippo/widget/refreshlayout/SwipeProgressBar.java b/app/src/main/java/com/hippo/widget/refreshlayout/SwipeProgressBar.java index f15e91af2..577149ae0 100644 --- a/app/src/main/java/com/hippo/widget/refreshlayout/SwipeProgressBar.java +++ b/app/src/main/java/com/hippo/widget/refreshlayout/SwipeProgressBar.java @@ -38,7 +38,7 @@ import android.view.animation.Interpolator; */ final class SwipeProgressBar { - private static final boolean SUPPORT_CLIPRECT_DIFFERENCE = + private static final boolean SUPPORT_CLIP_RECT_DIFFERENCE = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2; // Default progress animation colors are grays. @@ -68,9 +68,9 @@ final class SwipeProgressBar { private int mColor2; private int mColor3; private int mColor4; - private View mParent; + private final View mParent; - private Rect mBounds = new Rect(); + private final Rect mBounds = new Rect(); public SwipeProgressBar(View parent) { mParent = parent; @@ -182,7 +182,7 @@ final class SwipeProgressBar { float pct = (finishProgress / 100f); // Radius of the circle is half of the screen. float clearRadius = width / 2 * INTERPOLATOR.getInterpolation(pct); - if (SUPPORT_CLIPRECT_DIFFERENCE) { + if (SUPPORT_CLIP_RECT_DIFFERENCE) { mClipRect.set(cx - clearRadius, bounds.top, cx + clearRadius, bounds.bottom); canvas.clipRect(mClipRect, Region.Op.DIFFERENCE); } else {