ClockView package androidart.org.androidart.view;import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.support.annotation.Nullable;import android.util.Attrib
package androidart.org.androidart.view; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.util.Log; import android.view.View; import java.util.Calendar; public class ClockView extends View{ private float clockRadius = 300; private Paint clockPaint; private float centerX; private float centerY; private final static int HOURS = 12; private final static int HOUR_0 = 0; private final static int HOUR_3 = 3; private final static int HOUR_6 = 6; private final static int HOUR_9 = 9; private final static int HOUR_0_3_6_9_SIZE = 50; private final static int HOUR_OTHERS_SIZE = HOUR_0_3_6_9_SIZE/2; private final static int HOUR_ARROW_SIZE = 200; private final static int MINUTE_ARROW_SIZE = 250; private final static int SECOND_ARROW_SIZE = MINUTE_ARROW_SIZE; private Calendar calendar; private int currentHour; private int currentMinute; private int currentSecond; private static final int TIME_BASE = 60; Paint secondPaint = new Paint(); public ClockView(Context context) { this(context,null); } public ClockView(Context context, @Nullable AttributeSet attrs) { this(context,attrs,-1); } public ClockView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } private void init() { clockPaint = new Paint(); clockPaint.setStyle(Paint.Style.STROKE); clockPaint.setStrokeWidth(10); centerX = getLeft()+clockRadius; centerY = getTop()+clockRadius; } private void drawHourBase(Canvas canvas) { for (int i=0;istart && num