CompactCalendarView icon indicating copy to clipboard operation
CompactCalendarView copied to clipboard

setCurrentDate does't trigger onDayClick event

Open ghost opened this issue 6 years ago • 2 comments

Hello, when I call setCurrentDate, the event onDayClick is not being triggered. I need a way to simulate a user day clicking programmatically to show day events after month scroll or when I finish loading all current month events.

Is there any way to achieve this? I think this is needed.

ghost avatar Oct 11 '19 11:10 ghost

Did you manage to solve this? I need it as well...

giampa-cz avatar Jan 13 '21 10:01 giampa-cz

I don't remember exactly how I made, but I have a workaround that makes the tick:

I have a spinner to change current month, and I have this event:

Global var private var currentFirstDayOfNewMonth: Date? = null

`this.slcMeses.onItemSelectedListener = object: AdapterView.OnItemSelectedListener{ override fun onNothingSelected(parent: AdapterView<*>?) {}

        override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
            val hoy = Date()
            val cal = Calendar.getInstance()
            cal.time = currentFirstDayOfNewMonth as Date
            cal.set(Calendar.MONTH, position)

            if(hoy.getYear() == this.year && hoy.getMonth() == position){
                cal.set(Calendar.DAY_OF_MONTH, hoy.getDayOfMonth())
            }
            else{
                cal.set(Calendar.DAY_OF_MONTH, 1)
            }

            this.compactCalendarView.setCurrentDate(cal.time)
            currentFirstDayOfNewMonth = compactCalendarView.firstDayOfCurrentMonth
        }
    }`

Hope this will help, I don't remember what I thought😂

miguelangelss4 avatar Jan 13 '21 10:01 miguelangelss4