@Override public void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawRect(new Rect(0, 0, mViewWidth, mViewHeight), new Paint()); if (mIsInitTime) { mIsInitTime = false; } else { refreshAngle(); } if (mIsTouchMode) { mSecondAngle = 0; } mMinuteMatrix.preRotate( mMinuteAngle, mMinuteBitmap.getWidth() / 2f, mMinuteBitmap.getHeight() / 2f); mHourMatrix.preRotate(mHourAngle, mHourBitmap.getWidth() / 2f, mHourBitmap.getHeight() / 2f); mSecondMatrix.preRotate( mSecondAngle, mSecondBitmap.getWidth() / 2f, mSecondBitmap.getHeight() / 2f); int date_minute = (int) Math.floor(mMinuteNewAllAngle / 6); int date_hour = (int) Math.floor(mHourNewAllAngle / 30); mCalendar = Calendar.getInstance(); int date_second = mCalendar.get(Calendar.SECOND); canvas.drawBitmap(mBackGroundBitmap, 0, 0, null); canvas.drawBitmap(mHourBitmap, mHourMatrix, null); canvas.drawBitmap(mMinuteBitmap, mMinuteMatrix, null); canvas.drawBitmap(mSecondBitmap, mSecondMatrix, null); if (mIsTouchMode) { mOnTimeChangeListener.onTimeChange(date_hour == 0 ? 12 : date_hour, date_minute, date_second); } }
public void myInvalidate() { mIsInit = true; mIsInitTime = true; super.invalidate(); }