prolificinteractive / material-calendarview

A Material design back port of Android's CalendarView
https://prolificinteractive.github.io/material-calendarview/
MIT License
5.91k stars 1.32k forks source link

Strange behaviour of decorators #1042

Closed miguelpenc closed 4 years ago

miguelpenc commented 4 years ago

Hi. I have a simple CalendarView that shows events. The events are stored in a database that is updated every now and then. I set customs decorators inside OnCreateView for five posible events,

        calendar.addDecorator(RoutineDecorator(requireActivity(), viewModel, 1))
        calendar.addDecorator(RoutineDecorator(requireActivity(), viewModel, 2))
        calendar.addDecorator(RoutineDecorator(requireActivity(), viewModel, 3))
        calendar.addDecorator(RoutineDecorator(requireActivity(), viewModel, 4))
        calendar.addDecorator(RoutineDecorator(requireActivity(), viewModel, 5))

The RoutineDecorator generates the drawables acording to the last argument, and parses a list of events, comparing each day within a event to see if belongs to the Decorator 1 to 5.

When I open the app, the decorators do not show. If I scroll two months back and forth past the dates where I have events, everything works perfectly. If I update the database and scroll, the events get updated acordingly. In resume, if I move a couple of months back and forth, everything works like a charm.

I thought by reading the documentation that I should trigger Calendar.invalidateDecorators() to refresh the decorators shown, but if I do it, the app crashes complaining of OOM. So I am wondering, what does the calendar do when I scroll to months that is different from this function and how can I trigger it manually.

Thanks

miguelpenc commented 4 years ago

The CalendarView wasn't to blame, sorry