package com.github.anastr.speedviewlib.components.Indicators;

import android.content.Context;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;

/**
 * this Library build By Anas Altair
 * see it on <a href="https://github.com/anastr/SpeedView">GitHub</a>
 */

public class NeedleIndicator extends Indicator {

    private Path indicatorPath = new Path();

    public NeedleIndicator(Context context) {
        super(context);
        updateIndicator();
    }

    @Override
    protected float getDefaultIndicatorWidth() {
        return dpTOpx(12f);
    }

    @Override
    public void draw(Canvas canvas, float degree) {
        canvas.save();
        canvas.rotate(90f + degree, getCenterX(), getCenterY());
        canvas.drawPath(indicatorPath, indicatorPaint);
        canvas.restore();
    }

    @Override
    protected void updateIndicator() {
        indicatorPath.reset();
        indicatorPath.moveTo(getCenterX(), getPadding());
        float y = (float) (getIndicatorWidth() * Math.sin(265)) + getViewSize()*.5f + getPadding();
        float xLeft = (float) (getIndicatorWidth() * Math.cos(265)) + getViewSize()*.5f + getPadding();
        indicatorPath.lineTo(xLeft, y);
        RectF rectF = new RectF(getCenterX() - getIndicatorWidth(), getCenterX() - getIndicatorWidth()
                , getCenterX() + getIndicatorWidth(), getCenterX() + getIndicatorWidth());
        indicatorPath.arcTo(rectF, 265, -10f);
        indicatorPath.addCircle(getCenterX(), getCenterY(), getIndicatorWidth(), Path.Direction.CW);

        indicatorPaint.setColor(getIndicatorColor());
    }

    @Override
    protected void setWithEffects(boolean withEffects) {
        if (withEffects && !isInEditMode()) {
            indicatorPaint.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.SOLID));
        }
        else {
            indicatorPaint.setMaskFilter(null);
        }
    }
}

@@ -160,16 +160,47 @@
 Canvas;%0A
+import android.graphics.Paint;%0A
 import a
@@ -463,16 +463,125 @@
  Path();
+%0A    private Path circlePath = new Path();%0A    private Paint circlePaint =  new Paint(Paint.ANTI_ALIAS_FLAG);
 %0A%0A    pu
@@ -640,24 +640,74 @@
 r(context);%0A
+        circlePaint.setStyle(Paint.Style.STROKE);%0A
         upda
@@ -1032,24 +1032,74 @@
 atorPaint);%0A
+        canvas.drawPath(circlePath, circlePaint);%0A
         canv
@@ -1199,24 +1199,52 @@
 th.reset();%0A
+        circlePath.reset();%0A
         indi
@@ -1347,19 +1347,35 @@
 ath.sin(
-265
+Math.toRadians(260)
 )) + get
@@ -1471,13 +1471,29 @@
 cos(
+Math.toRadians(
 26
-5
+0
 ))
+)
  + g
@@ -1634,33 +1634,33 @@
 dth(), getCenter
-X
+Y
 () - getIndicato
@@ -1723,33 +1723,33 @@
 dth(), getCenter
-X
+Y
 () + getIndicato
@@ -1800,26 +1800,26 @@
 , 26
-5, -1
+0, 2
 0f);%0A
+%0A
         
 indi
@@ -1810,33 +1810,85 @@
 );%0A%0A        
-indicator
+float circleWidth = getIndicatorWidth() *.25f;%0A        circle
 Path.addCirc
@@ -1937,16 +1937,39 @@
 rWidth()
+ - circleWidth*.5f +.6f
 , Path.D
@@ -2033,24 +2033,124 @@
 orColor());%0A
+        circlePaint.setColor(getIndicatorColor());%0A        circlePaint.setStrokeWidth(circleWidth);%0A
     %7D%0A%0A    @
@@ -2258,18 +2258,16 @@
 tMode())
- %7B
 %0A       
@@ -2352,26 +2352,16 @@
 OLID));%0A
-        %7D%0A
         
@@ -2364,18 +2364,16 @@
     else
- %7B
 %0A       
@@ -2417,18 +2417,8 @@
 l);%0A
-        %7D%0A
     

fix NeedleIndicator shape.