MaterialDatePicker is very very slow

294 Views Asked by At

I have the following function -

    private fun showCalendar() {
        val datePickerDialog = MaterialDatePicker
            .Builder
            .dateRangePicker()
            .setTheme(R.style.ThemeOverlay_MaterialComponents_MaterialCalendar).build()
        datePickerDialog.addOnPositiveButtonClickListener {
            binding.fragmentInspectionDateTextView.text =
                getString(R.string.date_range, it.first?.toFormattedDate("dd/MM"), it.second?.toFormattedDate("dd/MM"))
            binding.fragmentInspectionSwipeToRefreshLayout.isRefreshing = true
            handleRefresh()
        }
        datePickerDialog.show(parentFragmentManager, null)
    }

It renders the MaterialDatePicker very, very slow. Like a couple of seconds slow.

I couldn't figure out what was wrong. From checking similar threads at the subject it could be related to some effect happening in slow motion but I couldn't verify that.

Is there a way to make the dialog pop immediately?

0

There are 0 best solutions below