@@ -494,29 +494,8 @@ protected void onDraw(Canvas canvas) {
494
494
drawTimeColumnAndAxes (canvas );
495
495
}
496
496
497
- private void drawTimeColumnAndAxes (Canvas canvas ) {
498
- // Draw the background color for the header column.
499
- canvas .drawRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), mHeaderColumnBackgroundPaint );
500
-
501
- // Clip to paint in left column only.
502
- canvas .clipRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), Region .Op .REPLACE );
503
-
504
- for (int i = 0 ; i < 24 ; i ++) {
505
- float top = mHeaderHeight + mHeaderRowPadding * 2 + mCurrentOrigin .y + mHourHeight * i + mHeaderMarginBottom ;
506
-
507
- // Draw the text if its y position is not outside of the visible area. The pivot point of the text is the point at the bottom-right corner.
508
- String time = getDateTimeInterpreter ().interpretTime (i );
509
- if (time == null )
510
- throw new IllegalStateException ("A DateTimeInterpreter must not return null time" );
511
- if (top < getHeight ()) canvas .drawText (time , mTimeTextWidth + mHeaderColumnPadding , top + mTimeTextHeight , mTimeTextPaint );
512
- }
513
- }
514
-
515
- private void drawHeaderRowAndEvents (Canvas canvas ) {
516
- // Calculate the available width for each day.
517
- mHeaderColumnWidth = mTimeTextWidth + mHeaderColumnPadding *2 ;
518
- mWidthPerDay = getWidth () - mHeaderColumnWidth - mColumnGap * (mNumberOfVisibleDays - 1 );
519
- mWidthPerDay = mWidthPerDay /mNumberOfVisibleDays ;
497
+ private void calculateHeaderHeight (){
498
+ //Make sure the header is the right size (depends on AllDay events)
520
499
boolean containsAllDayEvent = false ;
521
500
if (mEventRects != null && mEventRects .size () > 0 ) {
522
501
for (int dayNumber = 0 ;
@@ -536,17 +515,39 @@ private void drawHeaderRowAndEvents(Canvas canvas) {
536
515
}
537
516
}
538
517
}
539
- float newHeaderHeight ;
540
518
if (containsAllDayEvent ) {
541
- newHeaderHeight = mHeaderTextHeight + (mAllDayEventHeight + mHeaderMarginBottom );
519
+ mHeaderHeight = mHeaderTextHeight + (mAllDayEventHeight + mHeaderMarginBottom );
542
520
}
543
521
else {
544
- newHeaderHeight = mHeaderTextHeight ;
522
+ mHeaderHeight = mHeaderTextHeight ;
545
523
}
546
- if (newHeaderHeight !=mHeaderHeight ){
547
- mHeaderHeight = newHeaderHeight ;
548
- postInvalidate ();
524
+ }
525
+
526
+ private void drawTimeColumnAndAxes (Canvas canvas ) {
527
+ // Draw the background color for the header column.
528
+ canvas .drawRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), mHeaderColumnBackgroundPaint );
529
+
530
+ // Clip to paint in left column only.
531
+ canvas .clipRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), Region .Op .REPLACE );
532
+
533
+ for (int i = 0 ; i < 24 ; i ++) {
534
+ float top = mHeaderHeight + mHeaderRowPadding * 2 + mCurrentOrigin .y + mHourHeight * i + mHeaderMarginBottom ;
535
+
536
+ // Draw the text if its y position is not outside of the visible area. The pivot point of the text is the point at the bottom-right corner.
537
+ String time = getDateTimeInterpreter ().interpretTime (i );
538
+ if (time == null )
539
+ throw new IllegalStateException ("A DateTimeInterpreter must not return null time" );
540
+ if (top < getHeight ()) canvas .drawText (time , mTimeTextWidth + mHeaderColumnPadding , top + mTimeTextHeight , mTimeTextPaint );
549
541
}
542
+ }
543
+
544
+ private void drawHeaderRowAndEvents (Canvas canvas ) {
545
+ // Calculate the available width for each day.
546
+ mHeaderColumnWidth = mTimeTextWidth + mHeaderColumnPadding *2 ;
547
+ mWidthPerDay = getWidth () - mHeaderColumnWidth - mColumnGap * (mNumberOfVisibleDays - 1 );
548
+ mWidthPerDay = mWidthPerDay /mNumberOfVisibleDays ;
549
+
550
+ calculateHeaderHeight (); //Make sure the header is the right size (depends on AllDay events)
550
551
551
552
Calendar today = today ();
552
553
@@ -1003,6 +1004,7 @@ else if (periodToFetch == mFetchedPeriod+1){
1003
1004
sortAndCacheEvents (previousPeriodEvents );
1004
1005
sortAndCacheEvents (currentPeriodEvents );
1005
1006
sortAndCacheEvents (nextPeriodEvents );
1007
+ calculateHeaderHeight ();
1006
1008
1007
1009
mPreviousPeriodEvents = previousPeriodEvents ;
1008
1010
mCurrentPeriodEvents = currentPeriodEvents ;
0 commit comments