Skip to content

Commit 3b44a4c

Browse files
author
Jesse Hoobergs
committed
Fix AllDay events when it is shown on first draw
1 parent 9b73ac7 commit 3b44a4c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

library/src/main/java/com/alamkanak/weekview/WeekView.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ private void drawHeaderRowAndEvents(Canvas canvas) {
524524
dayNumber++) {
525525
Calendar day = (Calendar) getFirstVisibleDay().clone();
526526
day.add(Calendar.DATE, dayNumber);
527-
int amountOfAllDayEvents=0;
528527
for (int i = 0; i < mEventRects.size(); i++) {
529528

530529
if (isSameDay(mEventRects.get(i).event.getStartTime(), day) && mEventRects.get(i).event.isAllDay()) {
@@ -537,12 +536,21 @@ private void drawHeaderRowAndEvents(Canvas canvas) {
537536
}
538537
}
539538
}
539+
float newHeaderHeight;
540540
if(containsAllDayEvent) {
541-
mHeaderHeight = mHeaderTextHeight + (mAllDayEventHeight + mHeaderMarginBottom);
541+
newHeaderHeight = mHeaderTextHeight + (mAllDayEventHeight + mHeaderMarginBottom);
542542
}
543543
else{
544-
mHeaderHeight = mHeaderTextHeight;
544+
newHeaderHeight = mHeaderTextHeight;
545545
}
546+
if(newHeaderHeight!=mHeaderHeight){
547+
mHeaderHeight = newHeaderHeight;
548+
invalidate();
549+
}
550+
else{
551+
mHeaderHeight = newHeaderHeight;
552+
}
553+
546554
Calendar today = today();
547555

548556
if (mAreDimensionsInvalid) {

sample/src/main/java/com/alamkanak/weekview/sample/BasicActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public List<? extends WeekViewEvent> onMonthChange(int newYear, int newMonth) {
118118

119119
//AllDay event
120120
startTime = Calendar.getInstance();
121-
startTime.set(Calendar.DAY_OF_MONTH, 6);
121+
startTime.set(Calendar.DAY_OF_MONTH, 4);
122122
startTime.set(Calendar.HOUR_OF_DAY, 0);
123123
startTime.set(Calendar.MINUTE, 0);
124124
startTime.set(Calendar.MONTH, newMonth-1);

0 commit comments

Comments
 (0)