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

Preload view in MonthDayBinder #536

Open
nikunjparadvaAB opened this issue Mar 12, 2024 · 3 comments
Open

Preload view in MonthDayBinder #536

nikunjparadvaAB opened this issue Mar 12, 2024 · 3 comments

Comments

@nikunjparadvaAB
Copy link

Library information:

  • Version: 2.4.1
  • View or Compose module: View

Question:

for swipe smoothly, How to Preload data in MonthDayBinder for previous and next month?

When i swipe the month then it lags some milliseconds. so what to do for preload views for some months?

  exFiveCalendar.dayBinder = object : MonthDayBinder<DayViewContainer> {
                override fun create(view: View) = DayViewContainer(view)

                override fun bind(container: DayViewContainer, data: CalendarDay) {
                    container.binding.tvDate.text = data.date.dayOfMonth.toString()
                    // Some code for event previews
                }
            }

I have this output

Screenshot_20240312_154634

@kizitonwose
Copy link
Owner

This is a bit tricky but you'll need to override the internal layout manager and override calculateExtraLayoutSpace.

See documentation

@nikunjparadvaAB
Copy link
Author

how to add calculateExtraLayoutSpace for this?

<com.kizitonwose.calendar.view.CalendarView
        android:id="@+id/exFiveCalendar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:cv_daySize="rectangle"
        android:background="@color/month_divider"
        app:cv_dayViewResource="@layout/item_month_day"
        app:cv_outDateStyle="endOfGrid" />

@kizitonwose
Copy link
Owner

There's no way to do this via xml presently.

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

2 participants