android – Applandeo / Material-Calendar-View issue where events added to the calendarView does not populates only for January 2020-ThrowExceptions

Exception or error:

The Applandeo / Material-Calendar-View library is not showing events only for January 2020. The events drawable pops up only when I click any of the date in the January month, not automatically like other months. For all other months the events drawable works perfectly. I have attached a video url regarding the same issue.

https://drive.google.com/open?id=1bdrP3hw16fCiy3aZsVlKtaLlauQbiMvv

The code snippet used to set the events are as below :

private void addCalendarViewEvent(String stringDate, String type) {

    DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
    try {
        format.parse(stringDate);

        Calendar calendar = Calendar.getInstance();
        calendar.set(DateAndTime.getyyyyFromFormattedDate(stringDate),
                DateAndTime.getMMFromFormattedDate(stringDate) - 1,
                DateAndTime.getddFromFormattedDate(stringDate));

        switch (type) {
            case "A":
                eventDayList.add(new EventDay(calendar, R.drawable.red_pill));
                break;
            case "H":
                eventDayList.add(new EventDay(calendar, R.drawable.orange_pill));
                break;
            case "P":
                eventDayList.add(new EventDay(calendar, R.drawable.green_pill));
                break;
        }

        calendarView.setEvents(eventDayList);

    } catch (ParseException e) {
        e.printStackTrace();
        FirebaseCrashlytics.getInstance().recordException(e);
    }

}

Can anyone help for this issue. Thanks in advance.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *