From 39880a31850ffccd9174dbe660e4b8e42bd9d9d8 Mon Sep 17 00:00:00 2001 From: Sergio Durand Date: Tue, 25 Jul 2017 21:11:22 -0300 Subject: [PATCH] Add the third event to calendar before start to use plus sign Signed-off-by: Sergio Durand --- .../CompactCalendarController.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/github/sundeepk/compactcalendarview/CompactCalendarController.java b/library/src/main/java/com/github/sundeepk/compactcalendarview/CompactCalendarController.java index 9a22199c..10b912d5 100755 --- a/library/src/main/java/com/github/sundeepk/compactcalendarview/CompactCalendarController.java +++ b/library/src/main/java/com/github/sundeepk/compactcalendarview/CompactCalendarController.java @@ -778,8 +778,10 @@ void drawEvents(Canvas canvas, Calendar currentMonthToDrawCalender, int offset) yPosition += indicatorOffset; } - if (eventsList.size() >= 3) { + if (eventsList.size() >= 4) { drawEventsWithPlus(canvas, xPosition, yPosition, eventsList); + } else if (eventsList.size() == 3) { + drawThreeEvents(canvas, xPosition, yPosition, eventsList); } else if (eventsList.size() == 2) { drawTwoEvents(canvas, xPosition, yPosition, eventsList); } else if (eventsList.size() == 1) { @@ -797,12 +799,21 @@ private void drawSingleEvent(Canvas canvas, float xPosition, float yPosition, Li } private void drawTwoEvents(Canvas canvas, float xPosition, float yPosition, List eventsList) { - //draw fist event just left of center + //draw first event just left of center drawEventIndicatorCircle(canvas, xPosition + (xIndicatorOffset * -1), yPosition, eventsList.get(0).getColor()); //draw second event just right of center drawEventIndicatorCircle(canvas, xPosition + (xIndicatorOffset * 1), yPosition, eventsList.get(1).getColor()); } + private void drawThreeEvents(Canvas canvas, float xPosition, float yPosition, List eventsList) { + //draw first event just left of center + drawEventIndicatorCircle(canvas, xPosition + (xIndicatorOffset * -2), yPosition, eventsList.get(0).getColor()); + //draw second event centered + drawEventIndicatorCircle(canvas, xPosition, yPosition, eventsList.get(1).getColor()); + //draw third event just right of center + drawEventIndicatorCircle(canvas, xPosition + (xIndicatorOffset * 2), yPosition, eventsList.get(2).getColor()); + } + //draw 2 eventsByMonthAndYearMap followed by plus indicator to show there are more than 2 eventsByMonthAndYearMap private void drawEventsWithPlus(Canvas canvas, float xPosition, float yPosition, List eventsList) { // k = size() - 1, but since we don't want to draw more than 2 indicators, we just stop after 2 iterations so we can just hard k = -2 instead