DateRangePicker icon indicating copy to clipboard operation
DateRangePicker copied to clipboard

selected dates with calendar on a dialog fragment in API 28

Open pfeijo opened this issue 6 years ago • 4 comments

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 avatar Jan 11 '19 15:01 pfeijo

@pfeijo, please, write all constants you use.

CoolMind avatar Jan 15 '19 10:01 CoolMind

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)
    ...
}

... }`

pfeijo avatar Jan 15 '19 15:01 pfeijo

/**

  • 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

savvisingh avatar Jan 17 '19 11:01 savvisingh

i tried to add the fixDialogDimens:

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

pfeijo avatar Jan 21 '19 14:01 pfeijo