From 3bf7dedb8ad5d71c9d43f5f059ebb65eab070a41 Mon Sep 17 00:00:00 2001 From: Jeffrey Starke Date: Mon, 15 Aug 2016 12:38:22 -0400 Subject: [PATCH] Add setter for line stroke and path effect --- .../com/wooplr/spotlight/SpotlightView.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Spotlight-library/src/main/java/com/wooplr/spotlight/SpotlightView.java b/Spotlight-library/src/main/java/com/wooplr/spotlight/SpotlightView.java index 2b32d73..1124e94 100755 --- a/Spotlight-library/src/main/java/com/wooplr/spotlight/SpotlightView.java +++ b/Spotlight-library/src/main/java/com/wooplr/spotlight/SpotlightView.java @@ -8,6 +8,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; +import android.graphics.PathEffect; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffXfermode; @@ -16,6 +17,7 @@ import android.os.Build; import android.os.Handler; import android.os.Looper; +import android.support.annotation.Nullable; import android.support.graphics.drawable.AnimatedVectorDrawableCompat; import android.support.v4.content.ContextCompat; import android.support.v7.widget.AppCompatImageView; @@ -167,7 +169,7 @@ public class SpotlightView extends FrameLayout { */ private long lineAnimationDuration = 300; private int lineStroke; - + private PathEffect lineEffect; private int lineAndArcColor = Color.parseColor("#eb273f"); @@ -567,6 +569,7 @@ private void addPathAnimation(Activity activity) { p.setStrokeCap(Paint.Cap.ROUND); p.setStrokeWidth(lineStroke); p.setColor(lineAndArcColor); + p.setPathEffect(lineEffect); NormalLineAnimDrawable animDrawable1 = new NormalLineAnimDrawable(p); if (lineAnimationDuration > 0) @@ -873,9 +876,13 @@ public void setLineAndArcColor(int lineAndArcColor) { this.lineAndArcColor = lineAndArcColor; } -// public void setLineStroke(int lineStroke) { -// this.lineStroke = lineStroke; -// } + public void setLineStroke(int lineStroke) { + this.lineStroke = lineStroke; + } + + public void setLineEffect(PathEffect pathEffect) { + this.lineEffect = pathEffect; + } public void setTypeface(Typeface typeface) { this.mTypeface = typeface; @@ -1029,10 +1036,15 @@ public Builder enableDismissAfterShown(boolean enable) { return this; } -// public Builder lineStroke(int stoke) { -// spotlightView.setLineStroke(Utils.dpToPx(stoke)); -// return this; -// } + public Builder lineStroke(int stroke) { + spotlightView.setLineStroke(Utils.dpToPx(stroke)); + return this; + } + + public Builder lineEffect(@Nullable PathEffect pathEffect) { + spotlightView.setLineEffect(pathEffect); + return this; + } public Builder setConfiguration(SpotlightConfig configuration) { spotlightView.setConfiguration(configuration);