Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setOnCalendarDayClickListener fires up on dates after setMaximumDate #468

Open
OmarMartinezMx opened this issue Oct 2, 2024 · 0 comments

Comments

@OmarMartinezMx
Copy link

OmarMartinezMx commented Oct 2, 2024

Version

1.9.2

XML (basic, just a little styling)

    <com.applandeo.materialcalendarview.CalendarView
        android:id="@+id/calendarView"
        android:contentDescription="@string/content_description_calendar"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        app:headerColor="@color/light"
        app:headerLabelColor="@color/text"
        app:forwardButtonSrc="@drawable/ic_chevron_right"
        app:previousButtonSrc="@drawable/ic_chevron_left"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView9" />

Fragment

I'm using viewBinding, on onCreateView method of the fragment I just set the max date according to the documentation:

    binding.calendarView.setMaximumDate(Calendar.getInstance())

After that I add the listener:

    binding.calendarView.setOnCalendarDayClickListener(object: OnCalendarDayClickListener{
          override fun onClick(calendarDay: CalendarDay) {
                Log.i(TAG, calendarDay.calendar.time.toString())
               
          }
    })

On the screen I can see the dates past the max date (set to the current day) gray out and I can't go to the next month, so that's ok.

But if I click on any day the listener get executed, is there a way to avoid this? For now I have a validation but I believe this should be handle by the component not the implementation, or maybe a configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant