savvisingh / DateRangePicker

Date Range Picker is a Calendar Picker View to show a Customized Date Range Picker with improved UI and functionality to add subtitles to the dates
Apache License 2.0
784 stars 160 forks source link

selected dates with calendar on a dialog fragment in API 28 #45

Open pfeijo opened 5 years ago

pfeijo commented 5 years ago

Hi, first of all thanks for your work, greatly appreciated. I'm using v1.2.0, the calendar seems not to scroll to selected dates that it is passed to it during init, this seems to be only reproducible on API28.

my code is as follows: calendar?.init(minDate.toDate(), maxDate.toDate(), SimpleDateFormat(UiUtils.MONTH_LONG_YEAR_FORMAT, locale))?.inMode(mode)?.setShortWeekdays(newShortWeekdays)?.withSelectedDates(list)

Any thoughts how to overcome this? Thanks in advance

CoolMind commented 5 years ago

@pfeijo, please, write all constants you use.

pfeijo commented 5 years ago

I'm using it in the following way:

`class DateRangePickerFragment : android.support.v4.app.DialogFragment() {

private var session: Session? = null
private var rootView: View? = null
private var calendar: CalendarPickerView? = null
private var minDate = DateTime(1989, 12, 31, 0, 0, 0)
private val maxDate = DateTime(2039, 12, 31, 0, 0, 0)

...

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
    ...
    calendar = rootView?.findViewById(DateRangeUI.calendar)
    val mode = CalendarPickerView.SelectionMode.RANGE
    val locale = Locale.getDefault()
    calendar?.init(minDate.toDate(), maxDate.toDate(), SimpleDateFormat(UiUtils.MONTH_LONG_YEAR_FORMAT, locale))
            ?.inMode(mode)
            ?.withSelectedDates(list)
    ...
}

... }`

savvisingh commented 5 years ago

/**

Can you please try to call this method and let me know if it works

pfeijo commented 5 years ago

i tried to add the fixDialogDimens:

using OnShowListener nothing is changed as it does not seems to be called
using onStart() -> the calendar disappears.