DateRangePicker
DateRangePicker copied to clipboard
selected dates with calendar on a dialog fragment in API 28
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
@pfeijo, please, write all constants you use.
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)
...
}
... }`
/**
- This method should only be called if the calendar is contained in a dialog, and it should only
- be called once, right after the dialog is shown (using
- {@link android.content.DialogInterface.OnShowListener} or
- {@link android.app.DialogFragment#onStart()}). */ public void fixDialogDimens()
Can you please try to call this method and let me know if it works
i tried to add the fixDialogDimens:
using OnShowListener nothing is changed as it does not seems to be called
using onStart() -> the calendar disappears.