diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java index 6fad249780..88fe385084 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java @@ -8,6 +8,7 @@ import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; class Bubble extends Drawable { @@ -16,14 +17,16 @@ class Bubble extends Drawable { private float arrowHeight; private float arrowPosition; private float cornersRadius; + @NonNull private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); private float strokeWidth; private Paint strokePaint; private Path strokePath; + @NonNull private Path path = new Path(); - Bubble(RectF rect, ArrowDirection arrowDirection, float arrowWidth, float arrowHeight, float arrowPosition, - float cornersRadius, int bubbleColor, float strokeWidth, int strokeColor) { + Bubble(@NonNull RectF rect, @NonNull ArrowDirection arrowDirection, float arrowWidth, float arrowHeight, + float arrowPosition, float cornersRadius, int bubbleColor, float strokeWidth, int strokeColor) { this.rect = rect; this.arrowWidth = arrowWidth; this.arrowHeight = arrowHeight; @@ -49,7 +52,7 @@ class Bubble extends Drawable { } @Override - public void draw(Canvas canvas) { + public void draw(@NonNull Canvas canvas) { if (strokeWidth > 0) { canvas.drawPath(strokePath, strokePaint); } @@ -81,7 +84,7 @@ class Bubble extends Drawable { return (int) rect.height(); } - private void initPath(ArrowDirection arrowDirection, Path path, float strokeWidth) { + private void initPath(@NonNull ArrowDirection arrowDirection, @NonNull Path path, float strokeWidth) { switch (arrowDirection.getValue()) { case ArrowDirection.LEFT: if (cornersRadius <= 0) { @@ -138,7 +141,7 @@ class Bubble extends Drawable { } } - private void initLeftSquarePath(RectF rect, Path path, float strokeWidth) { + private void initLeftSquarePath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) { path.moveTo(arrowWidth + rect.left + strokeWidth, rect.top + strokeWidth); path.lineTo(rect.width() - strokeWidth, rect.top + strokeWidth); @@ -155,7 +158,7 @@ class Bubble extends Drawable { path.close(); } - private void initLeftRoundedPath(RectF rect, Path path, float strokeWidth) { + private void initLeftRoundedPath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) { path.moveTo(arrowWidth + rect.left + cornersRadius + strokeWidth, rect.top + strokeWidth); path.lineTo(rect.width() - cornersRadius - strokeWidth, rect.top + strokeWidth); path.arcTo(new RectF(rect.right - cornersRadius, rect.top + strokeWidth, rect.right - strokeWidth, @@ -184,7 +187,7 @@ class Bubble extends Drawable { path.close(); } - private void initTopSquarePath(RectF rect, Path path, float strokeWidth) { + private void initTopSquarePath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) { path.moveTo(rect.left + arrowPosition + strokeWidth, rect.top + arrowHeight + strokeWidth); path.lineTo(rect.left + arrowPosition + (strokeWidth / 2), rect.top + arrowHeight + strokeWidth); @@ -203,7 +206,7 @@ class Bubble extends Drawable { path.close(); } - private void initTopRoundedPath(RectF rect, Path path, float strokeWidth) { + private void initTopRoundedPath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) { path.moveTo(rect.left + Math.min(arrowPosition, cornersRadius) + strokeWidth, rect.top + arrowHeight + strokeWidth); path.lineTo(rect.left + arrowPosition + (strokeWidth / 2), rect.top + arrowHeight + strokeWidth); @@ -231,7 +234,7 @@ class Bubble extends Drawable { path.close(); } - private void initRightSquarePath(RectF rect, Path path, float strokeWidth) { + private void initRightSquarePath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) { path.moveTo(rect.left + strokeWidth, rect.top + strokeWidth); path.lineTo(rect.width() - arrowWidth - strokeWidth, rect.top + strokeWidth); @@ -247,7 +250,7 @@ class Bubble extends Drawable { path.close(); } - private void initRightRoundedPath(RectF rect, Path path, float strokeWidth) { + private void initRightRoundedPath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) { path.moveTo(rect.left + cornersRadius + strokeWidth, rect.top + strokeWidth); path.lineTo(rect.width() - cornersRadius - arrowWidth - strokeWidth, rect.top + strokeWidth); path.arcTo(new RectF(rect.right - cornersRadius - arrowWidth, @@ -270,7 +273,7 @@ class Bubble extends Drawable { path.close(); } - private void initBottomSquarePath(RectF rect, Path path, float strokeWidth) { + private void initBottomSquarePath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) { path.moveTo(rect.left + strokeWidth, rect.top + strokeWidth); path.lineTo(rect.right - strokeWidth, rect.top + strokeWidth); path.lineTo(rect.right - strokeWidth, rect.bottom - arrowHeight - strokeWidth); @@ -285,7 +288,7 @@ class Bubble extends Drawable { path.close(); } - private void initBottomRoundedPath(RectF rect, Path path, float strokeWidth) { + private void initBottomRoundedPath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) { path.moveTo(rect.left + cornersRadius + strokeWidth, rect.top + strokeWidth); path.lineTo(rect.width() - cornersRadius - strokeWidth, rect.top + strokeWidth); path.arcTo(new RectF(rect.right - cornersRadius, |