Slide 9
Slide 9 text
override fun getAutofillType(): Int {
return AUTOFILL_TYPE_DATE
}
override fun getAutofillValue(): AutofillValue {
val calendar = Calendar.getInstance()
calendar.clear()
val (year, month) = sanitize(text?.toString())
calendar.set(Calendar.YEAR, year)
calendar.set(Calendar.MONTH, month)
val unixTime: Long = calendar.timeInMillis
return AutofillValue.forDate(unixTime)
}
override fun autofill(value: AutofillValue) {
if (!value.isDate) {
return
}
val calendar = Calendar.getInstance()
calendar.timeInMillis = value.dateValue
setText(DateFormat.format("MM/yy", calendar))
}