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

DayLayout.getDayView returning wrong DayView when first time invoked #14

Open
TKolbusz opened this issue Jan 8, 2017 · 3 comments
Open

Comments

@TKolbusz
Copy link

TKolbusz commented Jan 8, 2017

As title says,
Logcat
// first invocation
D/DayLayout: setSelectedDay Mon Jan 02 12:55:21 GMT 2017
D/DayLayout: setSelectedDay2 DayView(Sun Jan 01 12:55:21 GMT 2017)
//2nd invocation
D/DayLayout: setSelectedDay Mon Jan 02 12:55:21 GMT 2017
D/DayLayout: setSelectedDay2 DayView(Mon Jan 02 12:55:21 GMT 2017)

DayLayout.kt

    fun setSelectedDay(date: Date) {
        Log.d("DayLayout", "setSelectedDay " + date.toString())
        setSelectedDay(getDayView(date))
    }

    fun getDayView(date: Date): DayView? = childList.getOrNull(date.daysAfter(firstDate.time).toInt()) as? DayView

    private fun setSelectedDay(view: DayView?) {
        Log.d("DayLayout","setSelectedDay2 " + view.toString())
        selectedDayView?.apply {
            isSelected = false
            updateState()
        }
        selectedDayView = view?.apply {
            isSelected = true
            updateState()
            callback?.onDateSelected(date)
        }
    }

Edit:

After further investigation I came to conclusion that date.DaysAfter(firstDate.time) is returning wrong value if date and firstDate.time are the same. Essentially it means that when you select date when view is inflated(like me) you'll get wrong DayView selected. Solution for that is setting date and firstDate.time fields MINUTE and HOUR to 0, and adding 1 to the return value of daysAfter func

@recruit-mahayash
Copy link
Contributor

recruit-mahayash commented Jan 13, 2017

Hi @TKolbusz,

I apologize for the delay in replying to you.

Thanks a lot for the issue and further investigations! We are now working on enhancements and bug-fixes including this in our private repository. The next version will be soon released.

Thank you.

@recruit-mahayash
Copy link
Contributor

@TKolbusz,

While developing the release version 1.0.1, we have tested calling the same method in the same situation, but the problem could not be reproduced. This issue may be somehow solved in Release 1.0.1. Could you confirm if the same problem occurs with the latest library version?

Thanks!

@TKolbusz
Copy link
Author

@recruit-mahayash Yep it works well in new release, the issue that I explained was really weird, it actually fixed itself by mistake, it was probably unreproducable because it was caused by my other changes in code.

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