The onDraw()
method paints the watch face with all necessary information. Follow the comments in the code to make complete sense of the following code snippet:
@Override public void onDraw(Canvas canvas, Rect bounds) { long now = System.currentTimeMillis(); mCalendar.setTimeInMillis(now); mDate.setTime(now); boolean is24Hour = DateFormat.is24HourFormat(TodayWatchFaceService.this); // Show colons for the first half of each second so the colons blink on when the time // updates. mShouldDrawColons = (System.currentTimeMillis() % 1000) < 500; // Draw the background. canvas.drawRect(0, 0, bounds.width(), bounds.height(), mBackgroundPaint); // Draw the hours. float x = mXOffset; String hourString; if (is24Hour) { hourString = formatTwoDigitNumber(mCalendar.get(Calendar.HOUR_OF_DAY)); } else { int hour = mCalendar.get(Calendar.HOUR); if (hour == 0) { hour = 12; } hourString...