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

The selected date wont change color after click button next/previous month #11

Open
www0488 opened this issue Sep 10, 2020 · 11 comments
Open

Comments

@www0488
Copy link

www0488 commented Sep 10, 2020

I have an UI Issue here which I don't know how to solve it.

The Calendar will display current selected date correct, the selected date will change it background. But when click the next/previous month and go back to the current month of year and try to select a date, the background wont change it color anymore.

I tested to debug & compare with the sample code from repo and I figured out object CalendarViewManager in my project does not triggered during the date selection after month has been changed. But when I tried the sample code from repo, the CalendarViewManager actually triggered and worked fine.

Does anyone had the same issue just like me?

@www0488
Copy link
Author

www0488 commented Sep 10, 2020

Problem found, The issue was caused by the version of constraintlayout in app Gradle build. If you have version which is higher than version 2.0.0-alpha3, your calendar selection will not working correctly when you change month. To walk around the issue, you have to decrease your constraintlayout version down to 2.0.0-alpha3 but the problem is still remains.

@miso01 Is there any chance you can fix it?

@misosvec
Copy link
Owner

@www0488 Thanks for creating issue. Currently I don't have time to maintain this library....

@rezwancs
Copy link

@www0488 the layout resources are being set while you are initializing the "SingleRowCalendar" object. So, after every time you are changing month, you could simply call init() function. that worked for me. Thank you.

@Jaydeepwebapprise
Copy link

Hello @RkPranto

I have tried your way but it's not working.
When we have to change the month using custom button than we had call init() funcation like this
singleRowCalendar.setDates(getDatesOfNextMonth())
singleRowCalendar.init()

        But not working 
        
        Can you please help me

@DeepikaDhammi
Copy link

I have an UI Issue here which I don't know how to solve it.

The Calendar will display current selected date correct, the selected date will change it background. But when click the next/previous month and go back to the current month of year and try to select a date, the background wont change it color anymore.

I tested to debug & compare with the sample code from repo and I figured out object CalendarViewManager in my project does not triggered during the date selection after month has been changed. But when I tried the sample code from repo, the CalendarViewManager actually triggered and worked fine.

Same issue i have found
Please help to triggered out, what we can do for it.

@amulaggarwal
Copy link

@miso01 can you help with this issue. The background of the selected date doesn't update after the month has been changed by any of the button. Tried to call init every time when month is changed....but its very slow and long press is called i don't know why. Please help

@Bhumil73
Copy link

Bhumil73 commented May 14, 2021

You need to assign init() property where you are clicking on the button for next and previous months. Just add the init(); statement inside the button's onClickListener function for both previous and next month buttons.

@kishansolanki124
Copy link

@miso01 you need to check this issue. Your sample code works for the selection of date even after the next/previous month change. But when we add your Gradle dependency, it is not working. When we change the month, then the date selection not working. Not only me, but many other developers are having this issue.

@dmnhat
Copy link

dmnhat commented Aug 31, 2021

As @Bhumil73 mentioned earlier , we need add Init() for both next and previous months action, and combining with the last chosen date likes this:

val myCalendarViewManager = object : CalendarViewManager { override fun setCalendarViewResourceId( position: Int, date: java.util.Date, isSelected: Boolean ): Int { return if (isSelected || chosenDate == date) R.layout.item_time_day_selected else R.layout.item_time_day }

@forceporquillo
Copy link

There's also a workaround to do this without the need to call the init() block every time a new list of dates is set.

It works on my implementation by adapting to ListAdapter<T, VH> instead of plain RecyclerView.Adapter<VH>. However, we need to fork this implementation in order to adapt the changes and refactor some areas in it, like if we want to maintain the current position of the list after invoking next/previous month, particularly the current date position.

@ShoaibKakal
Copy link

@forceporquillo can you please share your implementation.

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