muraee / Horizontal-Calendar

A material horizontal calendar view for Android based on RecyclerView
Apache License 2.0
1.21k stars 230 forks source link

gotoday select wrong day #117

Open KORuL opened 5 years ago

KORuL commented 5 years ago

Expected Behavior / Goal

I have tried this way in onResume method:

calendarHorizontal!!.goToday(true)
calendarHorizontal!!.refresh()

It almost always works fine, but some users receive a complaint about switching the calendar a day ago from the current date.

Actual Behavior

example: System date is 30.05.2019 but gotoday set 29.05.2019

Steps to Reproduce the Problem (sample code if possible)

            calendarHorizontal!!.goToday(true)
            calendarHorizontal!!.refresh()

Specifications

        calendarHorizontal = HorizontalCalendar.Builder(this, R.id.calendarViewHorizontal)
            .range(startDate, endDate)
            .datesNumberOnScreen(7)   // Number of Dates cells shown on screen (Recommended 5)
            .configure()
            .formatTopText("EEE")       // default to "MMM".
            .formatMiddleText("dd")    // default to "dd".
            .formatBottomText("MMM''yy")    // default to "EEE".
            .sizeBottomText(10f)
            .sizeTopText(14f)
            .sizeMiddleText(21f)
            .textColor(
                ContextCompat.getColor(applicationContext, R.color.new_black_unsel),
                ContextCompat.getColor(applicationContext, R.color.new_black_sel)
            )    // Text color for none selected Dates, Text color for selected Date.
            .selectedDateBackground(getResourses().getDrawable(R.drawable.gradient_selected_calendar))  // Background Drawable of the selected date cell.
            .selectorColor(
                ContextCompat.getColor(
                    applicationContext,
                    R.color.new_calendar_selector_color
                )
            )
            .end()
            .defaultSelectedDate(Calendar.getInstance())
            .build()
  • Android Version: 6.0
  • Horizontal-Calendar Version: 1.3.4
KORuL commented 5 years ago

I clone this repo!

        calendarHorizontal = HorizontalCalendar.Builder(this, R.id.calendarViewHorizontal)
            .range(startDate, endDate)
            .datesNumberOnScreen(8)   // Number of Dates cells shown on screen (Recommended 5)
            .configure()
            .formatTopText("EEE")       // default to "MMM".
            .formatMiddleText("dd")    // default to "dd".
            .formatBottomText("MMM''yy")    // default to "EEE".
            .sizeBottomText(10f)
            .sizeTopText(14f)
            .sizeMiddleText(21f)
            .textColor(
                ContextCompat.getColor(applicationContext, R.color.new_black_unsel),
                ContextCompat.getColor(applicationContext, R.color.new_black_sel)
            )    // Text color for none selected Dates, Text color for selected Date.
            .selectedDateBackground(getResourses().getDrawable(R.drawable.gradient_selected_calendar))  // Background Drawable of the selected date cell.
            .selectorColor(
                ContextCompat.getColor(
                    applicationContext,
                    R.color.new_calendar_selector_color
                )
            )
            .end()
            .defaultSelectedDate(Calendar.getInstance())
            .build()

if datesNumberOnScreen(8) - selecting incorrect date image

muraee commented 5 years ago

datesNumberOnScreen should be an odd number since the calendar will try to center the date on screen. Even numbers are not supported atm.

KORuL commented 5 years ago

Ok, I use datesNumberOnScreen(7) And everyone chooses the current date, however, the previous day is chosen in Kiev

dharmesh-om commented 3 years ago

@KORuL @Mulham-Raee Did you guys find any solution for this? when i am giving datesNumberOnScreen(7) // Number of Dates cells shown on screen its not working for selection on current date.

Only working for when i am giving dateNumberOnScreen(5).. Please help..