@SuppressWarnings("ConstantConditions") private void drawDays(Canvas canvas){
  final TextPaint p=mDayPaint;
  final int headerHeight=mMonthHeight + mDayOfWeekHeight;
  final float rowHeight=mDayHeight;
  final float colWidth=mCellWidth;
  final float halfLineHeight=(p.ascent() + p.descent()) / 2f;
  float rowCenter=headerHeight + rowHeight / 2f;
  for (int day=1, col=findDayOffset(); day <= mDaysInMonth; day++) {
    final float colCenter=colWidth * col + colWidth / 2f;
    final float colCenterRtl;
    if (SUtils.isLayoutRtlCompat(this)) {
      colCenterRtl=mPaddedWidth - colCenter;
    }
 else {
      colCenterRtl=colCenter;
    }
    int stateMask=0;
    final boolean isDayEnabled=isDayEnabled(day);
    if (isDayEnabled) {
      stateMask|=SUtils.STATE_ENABLED;
    }
    final boolean isDayInActivatedRange=mActivatedDays.isValid() && mActivatedDays.isActivated(day);
    final boolean isSelected=mActivatedDays.isSelected(day);
    if (isSelected) {
      stateMask|=SUtils.STATE_ACTIVATED;
      canvas.drawCircle(colCenterRtl,rowCenter,mDaySelectorRadius,mDaySelectorPaint);
    }
 else     if (isDayInActivatedRange) {
      stateMask|=SUtils.STATE_ACTIVATED;
      int bgShape=DRAW_RECT;
      if (mActivatedDays.isSingleDay()) {
        if (mActivatedDays.isStartOfMonth()) {
          bgShape=DRAW_RECT_WITH_CURVE_ON_RIGHT;
        }
 else {
          bgShape=DRAW_RECT_WITH_CURVE_ON_LEFT;
        }
      }
 else       if (mActivatedDays.isStartingDayOfRange(day)) {
        bgShape=DRAW_RECT_WITH_CURVE_ON_LEFT;
      }
 else       if (mActivatedDays.isEndingDayOfRange(day)) {
        bgShape=DRAW_RECT_WITH_CURVE_ON_RIGHT;
      }
      boolean constrainProtrusion=colWidth > (rowHeight - (2 * mPaddingRangeIndicator));
      float horDistFromCenter=constrainProtrusion ? rowHeight / 2f - mPaddingRangeIndicator : colWidth / 2f;
switch (bgShape) {
case DRAW_RECT_WITH_CURVE_ON_LEFT:
        int leftRectArcLeft=(int)(colCenterRtl - horDistFromCenter) % 2 == 1 ? (int)(colCenterRtl - horDistFromCenter) + 1 : (int)(colCenterRtl - horDistFromCenter);
      int leftRectArcRight=(int)(colCenterRtl + horDistFromCenter) % 2 == 1 ? (int)(colCenterRtl + horDistFromCenter) + 1 : (int)(colCenterRtl + horDistFromCenter);
    RectF leftArcRect=new RectF(leftRectArcLeft,rowCenter - rowHeight / 2f + mPaddingRangeIndicator,leftRectArcRight,rowCenter + rowHeight / 2f - mPaddingRangeIndicator);
  canvas.drawArc(leftArcRect,90,180,true,mDayRangeSelectorPaint);
canvas.drawRect(new RectF(leftArcRect.centerX(),rowCenter - rowHeight / 2f + mPaddingRangeIndicator,colCenterRtl + colWidth / 2f,rowCenter + rowHeight / 2f - mPaddingRangeIndicator),mDayRangeSelectorPaint);
break;
case DRAW_RECT_WITH_CURVE_ON_RIGHT:
int rightRectArcLeft=(int)(colCenterRtl - horDistFromCenter) % 2 == 1 ? (int)(colCenterRtl - horDistFromCenter) + 1 : (int)(colCenterRtl - horDistFromCenter);
int rightRectArcRight=(int)(colCenterRtl + horDistFromCenter) % 2 == 1 ? (int)(colCenterRtl + horDistFromCenter) + 1 : (int)(colCenterRtl + horDistFromCenter);
RectF rightArcRect=new RectF(rightRectArcLeft,rowCenter - rowHeight / 2f + mPaddingRangeIndicator,rightRectArcRight,rowCenter + rowHeight / 2f - mPaddingRangeIndicator);
canvas.drawArc(rightArcRect,270,180,true,mDayRangeSelectorPaint);
canvas.drawRect(new RectF(colCenterRtl - colWidth / 2f,rowCenter - rowHeight / 2f + mPaddingRangeIndicator,rightArcRect.centerX(),rowCenter + rowHeight / 2f - mPaddingRangeIndicator),mDayRangeSelectorPaint);
break;
default :
canvas.drawRect(new RectF(colCenterRtl - colWidth / 2f,rowCenter - rowHeight / 2f + mPaddingRangeIndicator,colCenterRtl + colWidth / 2f,rowCenter + rowHeight / 2f - mPaddingRangeIndicator),mDayRangeSelectorPaint);
break;
}
}
if (mTouchedItem == day) {
stateMask|=SUtils.STATE_PRESSED;
if (isDayEnabled) {
canvas.drawCircle(colCenterRtl,rowCenter,mDaySelectorRadius,mDayHighlightPaint);
}
}
final boolean isDayToday=mToday == day;
final int dayTextColor;
if (isDayToday && !isDayInActivatedRange) {
dayTextColor=mDaySelectorPaint.getColor();
}
 else {
final int[] stateSet=SUtils.resolveStateSet(stateMask);
dayTextColor=mDayTextColor.getColorForState(stateSet,0);
}
p.setColor(dayTextColor);
canvas.drawText(mDayFormatter.format(day),colCenterRtl,rowCenter - halfLineHeight,p);
col++;
if (col == DAYS_IN_WEEK) {
col=0;
rowCenter+=rowHeight;
}
}
}

@ SuppressWarnings ( "ConstantConditions" ) private void drawDays ( Canvas canvas ) { final TextPaint p = mDayPaint ; final int headerHeight = mMonthHeight + mDayOfWeekHeight ; final float rowHeight = mDayHeight ; final float colWidth = mCellWidth ; final float halfLineHeight = ( p . ascent ( ) + p . descent ( ) ) / 2f ; float rowCenter = headerHeight + rowHeight / 2f ; for ( int day = 1 , col = findDayOffset ( ) ; day <= mDaysInMonth ; day ++ ) { final float colCenter = colWidth * col + colWidth / 2f ; final float colCenterRtl ; if ( SUtils . isLayoutRtlCompat ( this ) ) { colCenterRtl = mPaddedWidth - colCenter ; } else { colCenterRtl = colCenter ; } int stateMask = 0 ; final boolean isDayEnabled = isDayEnabled ( day ) ; if ( isDayEnabled ) { stateMask |= SUtils . STATE_ENABLED ; } final boolean isDayInActivatedRange = mActivatedDays . isValid ( ) && mActivatedDays . isActivated ( day ) ; final boolean isSelected = mActivatedDays . isSelected ( day ) ; if ( isSelected ) { stateMask |= SUtils . STATE_ACTIVATED ; canvas . drawCircle ( colCenterRtl , rowCenter , mDaySelectorRadius , mDaySelectorPaint ) ; } else if ( isDayInActivatedRange ) { stateMask |= SUtils . STATE_ACTIVATED ; int bgShape = DRAW_RECT ; if ( mActivatedDays . isSingleDay ( ) ) { if ( mActivatedDays . isStartOfMonth ( ) ) { bgShape = DRAW_RECT_WITH_CURVE_ON_RIGHT ; } else { bgShape = DRAW_RECT_WITH_CURVE_ON_LEFT ; } } else if ( mActivatedDays . isStartingDayOfRange ( day ) ) { bgShape = DRAW_RECT_WITH_CURVE_ON_LEFT ; } else if ( mActivatedDays . isEndingDayOfRange ( day ) ) { bgShape = DRAW_RECT_WITH_CURVE_ON_RIGHT ; } boolean constrainProtrusion = colWidth > ( rowHeight - ( 2 * mPaddingRangeIndicator ) ) ; float horDistFromCenter = constrainProtrusion ? rowHeight / 2f - mPaddingRangeIndicator : colWidth / 2f ; switch ( bgShape ) { case DRAW_RECT_WITH_CURVE_ON_LEFT : int leftRectArcLeft = ( int ) ( colCenterRtl - horDistFromCenter ) % 2 == 1 ? ( int ) ( colCenterRtl - horDistFromCenter ) + 1 : ( int ) ( colCenterRtl - horDistFromCenter ) ; int leftRectArcRight = ( int ) ( colCenterRtl + horDistFromCenter ) % 2 == 1 ? ( int ) ( colCenterRtl + horDistFromCenter ) + 1 : ( int ) ( colCenterRtl + horDistFromCenter ) ; RectF leftArcRect = new RectF ( leftRectArcLeft , rowCenter - rowHeight / 2f + mPaddingRangeIndicator , leftRectArcRight , rowCenter + rowHeight / 2f - mPaddingRangeIndicator ) ; canvas . drawArc ( leftArcRect , 90 , 180 , true , mDayRangeSelectorPaint ) ; canvas . drawRect ( new RectF ( leftArcRect . centerX ( ) , rowCenter - rowHeight / 2f + mPaddingRangeIndicator , colCenterRtl + colWidth / 2f , rowCenter + rowHeight / 2f - mPaddingRangeIndicator ) , mDayRangeSelectorPaint ) ; break ; case DRAW_RECT_WITH_CURVE_ON_RIGHT : int rightRectArcLeft = ( int ) ( colCenterRtl - horDistFromCenter ) % 2 == 1 ? ( int ) ( colCenterRtl - horDistFromCenter ) + 1 : ( int ) ( colCenterRtl - horDistFromCenter ) ; int rightRectArcRight = ( int ) ( colCenterRtl + horDistFromCenter ) % 2 == 1 ? ( int ) ( colCenterRtl + horDistFromCenter ) + 1 : ( int ) ( colCenterRtl + horDistFromCenter ) ; RectF rightArcRect = new RectF ( rightRectArcLeft , rowCenter - rowHeight / 2f + mPaddingRangeIndicator , rightRectArcRight , rowCenter + rowHeight / 2f - mPaddingRangeIndicator ) ; canvas . drawArc ( rightArcRect , 270 , 180 , true , mDayRangeSelectorPaint ) ; canvas . drawRect ( new RectF ( colCenterRtl - colWidth / 2f , rowCenter - rowHeight / 2f + mPaddingRangeIndicator , rightArcRect . centerX ( ) , rowCenter + rowHeight / 2f - mPaddingRangeIndicator ) , mDayRangeSelectorPaint ) ; break ; default : canvas . drawRect ( new RectF ( colCenterRtl - colWidth / 2f , rowCenter - rowHeight / 2f + mPaddingRangeIndicator , colCenterRtl + colWidth / 2f , rowCenter + rowHeight / 2f - mPaddingRangeIndicator ) , mDayRangeSelectorPaint ) ; break ; } } if ( mTouchedItem == day ) { stateMask |= SUtils . STATE_PRESSED ; if ( isDayEnabled ) { canvas . drawCircle ( colCenterRtl , rowCenter , mDaySelectorRadius , mDayHighlightPaint ) ; } } final boolean isDayToday = mToday == day ; final int dayTextColor ; if ( isDayToday && ! isDayInActivatedRange ) { dayTextColor = mDaySelectorPaint . getColor ( ) ; } else { final int [ ] stateSet = SUtils . resolveStateSet ( stateMask ) ; dayTextColor = mDayTextColor . getColorForState ( stateSet , 0 ) ; } p . setColor ( dayTextColor ) ; canvas . drawText ( mDayFormatter . format ( day ) , colCenterRtl , rowCenter - halfLineHeight , p ) ; col ++ ; if ( col == DAYS_IN_WEEK ) { col = 0 ; rowCenter += rowHeight ; } } }
draws the month days .
