kizitonwose / Calendar

A highly customizable calendar view and compose library for Android.
MIT License
4.5k stars 492 forks source link

Calendar DaysView #538

Closed qtMety closed 2 months ago

qtMety commented 2 months ago

Library information:

Describe the bug**

When i scroll months I notice that a few days get randomly the "today's view". In the video that i will provide, the aspect that the "randomly days" get is the typeface bold and the size, but not the color red. The real problem is when, after i give an aspect to the other days this aspect is repeated each 3-4 month ( I can't provide a video for this because i re-writed the app 3 times thinking was a problem of mine)

To Reproduce (if applicable)

Steps to reproduce the behavior:

  1. Go to Calendar
  2. Swipe month
  3. See randomly days to get another aspect

Expected behavior (if applicable)

Days should not change randomly the aspect (like in the video, size and typeface)

Screenshots? (if applicable)

https://github.com/kizitonwose/Calendar/assets/166159362/b56f5617-072e-411f-b769-31498a4da82a 2 Feb, 3 Nov, 4 Aug changed aspect.

Additional information

This is the simple code i have at the moment (of the video) for the day's view (is taken from "Example 3 Fragment", but it happened also when i wrote manually using the documentation):

if (data.position == DayPosition.MonthDate) {
            textView.makeVisible()
            when (data.date) {
                today -> {
                    textView.setTextColorRes(R.color.red)
                    textView.setTypeface(textView.getTypeface(), Typeface.BOLD)
                    textView.setTextSizeRes(funForAll.spConvertToPx(textView.context, 12).toFloat())
                    dotView.makeInVisible()
                }
                selectedDate -> {
                    if(calendarViewModel.singleEditTime.value == false) {
                        textView.setTextColorRes(R.color.colorPrimary)
                        textView.setBackgroundResource(R.drawable.element_calendar_textview)
                        dotView.makeInVisible()
                    }
                }
                else -> {
                    textView.setTextColorRes(R.color.black)
                    textView.background = null
                    dotView.isVisible = events[data.date].orEmpty().isNotEmpty()
                }
            }
        } else {
            textView.makeInVisible()
            dotView.makeInVisible()
        }

Sorry for bad English, i hope you will understand it

UPDATE

The problem was the reuse of view, the color was set as default (black), the others no. Just add this in the else block:

                    textView.setTypeface(textView.getTypeface(), Typeface.BOLD)
                    textView.setTextSizeRes(funForAll.spConvertToPx(textView.context, 12).toFloat())