@@ -496,37 +496,15 @@ protected void onDraw(Canvas canvas) {
496
496
drawTimeColumnAndAxes (canvas );
497
497
}
498
498
499
- private void drawTimeColumnAndAxes (Canvas canvas ) {
500
- // Draw the background color for the header column.
501
- canvas .drawRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), mHeaderColumnBackgroundPaint );
502
-
503
- // Clip to paint in left column only.
504
- canvas .clipRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), Region .Op .REPLACE );
505
-
506
- for (int i = 0 ; i < 24 ; i ++) {
507
- float top = mHeaderHeight + mHeaderRowPadding * 2 + mCurrentOrigin .y + mHourHeight * i + mHeaderMarginBottom ;
508
-
509
- // 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.
510
- String time = getDateTimeInterpreter ().interpretTime (i );
511
- if (time == null )
512
- throw new IllegalStateException ("A DateTimeInterpreter must not return null time" );
513
- if (top < getHeight ()) canvas .drawText (time , mTimeTextWidth + mHeaderColumnPadding , top + mTimeTextHeight , mTimeTextPaint );
514
- }
515
- }
516
-
517
- private void drawHeaderRowAndEvents (Canvas canvas ) {
518
- // Calculate the available width for each day.
519
- mHeaderColumnWidth = mTimeTextWidth + mHeaderColumnPadding *2 ;
520
- mWidthPerDay = getWidth () - mHeaderColumnWidth - mColumnGap * (mNumberOfVisibleDays - 1 );
521
- mWidthPerDay = mWidthPerDay /mNumberOfVisibleDays ;
499
+ private void calculateHeaderHeight (){
500
+ //Make sure the header is the right size (depends on AllDay events)
522
501
boolean containsAllDayEvent = false ;
523
502
if (mEventRects != null && mEventRects .size () > 0 ) {
524
503
for (int dayNumber = 0 ;
525
504
dayNumber < mNumberOfVisibleDays ;
526
505
dayNumber ++) {
527
506
Calendar day = (Calendar ) getFirstVisibleDay ().clone ();
528
507
day .add (Calendar .DATE , dayNumber );
529
- int amountOfAllDayEvents =0 ;
530
508
for (int i = 0 ; i < mEventRects .size (); i ++) {
531
509
532
510
if (isSameDay (mEventRects .get (i ).event .getStartTime (), day ) && mEventRects .get (i ).event .isAllDay ()) {
@@ -545,6 +523,34 @@ private void drawHeaderRowAndEvents(Canvas canvas) {
545
523
else {
546
524
mHeaderHeight = mHeaderTextHeight ;
547
525
}
526
+ }
527
+
528
+ private void drawTimeColumnAndAxes (Canvas canvas ) {
529
+ // Draw the background color for the header column.
530
+ canvas .drawRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), mHeaderColumnBackgroundPaint );
531
+
532
+ // Clip to paint in left column only.
533
+ canvas .clipRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), Region .Op .REPLACE );
534
+
535
+ for (int i = 0 ; i < 24 ; i ++) {
536
+ float top = mHeaderHeight + mHeaderRowPadding * 2 + mCurrentOrigin .y + mHourHeight * i + mHeaderMarginBottom ;
537
+
538
+ // 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.
539
+ String time = getDateTimeInterpreter ().interpretTime (i );
540
+ if (time == null )
541
+ throw new IllegalStateException ("A DateTimeInterpreter must not return null time" );
542
+ if (top < getHeight ()) canvas .drawText (time , mTimeTextWidth + mHeaderColumnPadding , top + mTimeTextHeight , mTimeTextPaint );
543
+ }
544
+ }
545
+
546
+ private void drawHeaderRowAndEvents (Canvas canvas ) {
547
+ // Calculate the available width for each day.
548
+ mHeaderColumnWidth = mTimeTextWidth + mHeaderColumnPadding *2 ;
549
+ mWidthPerDay = getWidth () - mHeaderColumnWidth - mColumnGap * (mNumberOfVisibleDays - 1 );
550
+ mWidthPerDay = mWidthPerDay /mNumberOfVisibleDays ;
551
+
552
+ calculateHeaderHeight (); //Make sure the header is the right size (depends on AllDay events)
553
+
548
554
Calendar today = today ();
549
555
550
556
if (mAreDimensionsInvalid ) {
@@ -1000,6 +1006,7 @@ else if (periodToFetch == mFetchedPeriod+1){
1000
1006
sortAndCacheEvents (previousPeriodEvents );
1001
1007
sortAndCacheEvents (currentPeriodEvents );
1002
1008
sortAndCacheEvents (nextPeriodEvents );
1009
+ calculateHeaderHeight ();
1003
1010
1004
1011
mPreviousPeriodEvents = previousPeriodEvents ;
1005
1012
mCurrentPeriodEvents = currentPeriodEvents ;
@@ -1124,16 +1131,18 @@ private void computePositionOfEvents(List<EventRect> eventRects) {
1124
1131
List <List <EventRect >> collisionGroups = new ArrayList <List <EventRect >>();
1125
1132
for (EventRect eventRect : eventRects ) {
1126
1133
boolean isPlaced = false ;
1134
+
1127
1135
outerLoop :
1128
1136
for (List <EventRect > collisionGroup : collisionGroups ) {
1129
1137
for (EventRect groupEvent : collisionGroup ) {
1130
- if (isEventsCollide (groupEvent .event , eventRect .event )) {
1138
+ if (isEventsCollide (groupEvent .event , eventRect .event ) && groupEvent . event . isAllDay () == eventRect . event . isAllDay () ) {
1131
1139
collisionGroup .add (eventRect );
1132
1140
isPlaced = true ;
1133
1141
break outerLoop ;
1134
1142
}
1135
1143
}
1136
1144
}
1145
+
1137
1146
if (!isPlaced ) {
1138
1147
List <EventRect > newGroup = new ArrayList <EventRect >();
1139
1148
newGroup .add (eventRect );
0 commit comments