package hewking.github.customviewdemo.com.hewking.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by hewking on 2016/1/29.
 */
public class StarView extends View {

    private int mHeight;
    private int mWidth;

    public StarView(Context context) {
        this(context,null);
    }

    public StarView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public StarView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {

    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int wMode = MeasureSpec.getMode(widthMeasureSpec);
        int hMode = MeasureSpec.getMode(heightMeasureSpec);
        if(wMode == MeasureSpec.EXACTLY){
            mWidth = MeasureSpec.getSize(widthMeasureSpec);
        }

        if(hMode == MeasureSpec.EXACTLY){
             mHeight = MeasureSpec.getSize(heightMeasureSpec);
        }
        mWidth = mHeight > mWidth ? mHeight : mWidth;
        setMeasuredDimension(mWidth, mHeight);
    }

    @Override
    protected void onDraw(Canvas canvas) {



        super.onDraw(canvas);
    }
}

@@ -116,16 +116,139 @@
 Canvas;%0A
+import android.graphics.Color;%0Aimport android.graphics.Paint;%0Aimport android.graphics.Path;%0Aimport android.graphics.RectF;%0A
 import a
@@ -273,16 +273,16 @@
 uteSet;%0A
-
 import a
@@ -432,16 +432,43 @@
 Width;%0A%0A
+    private Paint mPaint;%0A%0A
     publ
@@ -802,17 +802,197 @@
 nit() %7B%0A
+        mPaint = new Paint();%0A        mPaint.setColor(Color.BLUE);%0A        mPaint.setStrokeWidth(2);%0A        mPaint.setStyle(Paint.Style.STROKE);%0A        mPaint.setAntiAlias(true);
 %0A
-
     %7D%0A%0A 
@@ -1593,16 +1593,693 @@
 vas) %7B%0A%0A
+        RectF rectF = new RectF(0, 0, mWidth, mHeight);%0A        Path path = new Path();%0A        canvas.drawRect(rectF,mPaint);%0A        path.moveTo(rectF.centerX(),rectF.centerY());%0A        for (int i =0 ; i %3C 5 ; i ++)%7B%0A            canvas.rotate(72,rectF.centerX(),rectF.centerY());%0A            canvas.drawCircle(rectF.centerX() + 100,rectF.centerY() + 100,1,mPaint);%0A            canvas.drawLine(rectF.centerX() + 30,rectF.centerY(),rectF.centerX() + 100,rectF.centerY() + 100,mPaint);%0A            canvas.drawLine(rectF.centerX(),rectF.centerY()+ 30,rectF.centerX() + 100,rectF.centerY() + 100,mPaint);%0A        %7D%0A        canvas.rotate(- 72 * 5,rectF.centerX(),rectF.centerY());
 %0A%0A      

update starview