Material-components-android: [MaterialDatePicker] NPE after EditText becomes empty

Created on 12 Sep 2019  路  1Comment  路  Source: material-components/material-components-android

Description: Setting the string to empty when using the MaterialDatePicker's manual input mode throws an NPE

java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
        at com.google.android.material.picker.SingleDateSelector$1.onValidDate(SingleDateSelector.java:103)
        at com.google.android.material.picker.DateFormatTextWatcher.onTextChanged(DateFormatTextWatcher.java:63)
        at android.widget.TextView.sendOnTextChanged(TextView.java:9754)

Expected behavior: It should handle the null value without any crash

Source code: Here's how I used it:

val datePicker = MaterialDatePicker.Builder
    .datePicker()
    .build()

datePicker.addOnPositiveButtonClickListener {
    Log.d("Test", it.toString())
}

datePicker.show(requireFragmentManager(), "test")

Android API version: 29

Material Library version: 1.1.0-alpha10
Device: Emulator on API 28

bug

Most helpful comment

We fixed this today. Thanks for the report.

>All comments

We fixed this today. Thanks for the report.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaychang0917 picture jaychang0917  路  3Comments

TdevM picture TdevM  路  3Comments

KelvinPac picture KelvinPac  路  3Comments

danielwilson1702 picture danielwilson1702  路  3Comments

zkovar picture zkovar  路  3Comments