michaldrabik / classicmaterialtimepicker

Classic Material Time Picker
57 stars 10 forks source link

`CmtpDateDialogFragment` crashing on saving `customDateSeparator` #11

Closed Him-khati closed 3 years ago

Him-khati commented 3 years ago

Thanks @michaldrabik for this library.

Just noticed that library is crashing when user has not supplied custom separator and library tries to save it's data on onSaveInstanceState

Logs

Fatal Exception: kotlin.UninitializedPropertyAccessException: lateinit property customDateSeparator has not been initialized
       at com.michaldrabik.classicmaterialtimepicker.CmtpDateDialogFragment.saveState(CmtpDateDialogFragment.kt:79)
       at com.michaldrabik.classicmaterialtimepicker.CmtpDateDialogFragment.onSaveInstanceState(CmtpDateDialogFragment.kt:158)
       at androidx.fragment.app.Fragment.performSaveInstanceState(Fragment.java:2864)      

Dependency

  implementation 'com.github.michaldrabik:classicmaterialtimepicker:1.1.3'

Usage

  private val dateOfBirthPicker: CmtpDateDialogFragment by lazy {

        val cal = Calendar.getInstance()
        CmtpDateDialogFragment.newInstance().apply {

            this.setInitialDate(cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1 , 1995)
            this.setCustomYearRange(1950, cal.get(Calendar.YEAR))
            this.setOnDatePickedListener(this)
        }
    }
michaldrabik commented 3 years ago

@Him-khati Thanks for reporting and PR. I'll review later.

michaldrabik commented 3 years ago

Released fix in 1.1.4