improve configure InputType

This commit is contained in:
Claire G 2022-08-11 16:13:36 +02:00
parent 5bb67ec253
commit 2364b68907

View File

@ -135,16 +135,9 @@ abstract class FormEditTextItem : VectorEpoxyModel<FormEditTextItem.Holder>(R.la
*/ */
private fun configureInputType(holder: Holder) { private fun configureInputType(holder: Holder) {
val newInputType = val newInputType =
inputType ?: when (singleLine) { inputType ?: InputType.TYPE_CLASS_TEXT
true -> { .let { if (autoCapitalize) it or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES else it }
if (autoCapitalize) InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES .let { if (!singleLine) it or InputType.TYPE_TEXT_FLAG_MULTI_LINE else it }
else InputType.TYPE_CLASS_TEXT
}
false -> {
if (autoCapitalize) InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
else InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
}
}
// This is a must in order to avoid extreme lag in some devices, on fast typing // This is a must in order to avoid extreme lag in some devices, on fast typing
if (holder.textInputEditText.inputType != newInputType) { if (holder.textInputEditText.inputType != newInputType) {