ognev-zair / Kotlin-AgendaCalendarView

Android calendar library provides easy to use widget with events
Apache License 2.0
96 stars 21 forks source link

Notify for new values #16

Open FlorianStock opened 2 years ago

FlorianStock commented 2 years ago

Hi,

How can we update the list of adapter ?

val calendarView : AgendaCalendarView = view.findViewById(R.id.agenda_calendar_view) adapter = AgendaAdapter(this.requireContext()) contentManager = CalendarContentManager(this, calendarView, adapter) contentManager.setDateRange(minDate, maxDate) contentManager.locale = Locale.FRENCH

    viewModel.interventionsListOfUser.observe(viewLifecycleOwner) { intervention ->
        eventList.clear()
        intervention.forEach { inter ->
            val dayStart = Calendar.getInstance()
            dayStart.time = Date(inter.startAt!!)
            val dayEnd = Calendar.getInstance()
            dayEnd.time = Date(inter.finishAt!!)

            val dayItem = DayItem.buildDayItemFromCal(dayStart)
            eventList.add(AgendaEvent(dayStart, dayEnd, dayItem, inter))
        }

    }
FlorianStock commented 2 years ago

Ok, i think my problem is resolved : https://github.com/ognev-zair/Kotlin-AgendaCalendarView/pulls I have duplcation of my values when i rotated the screen. Please accept the pull request. Thanks