From beab9ab8f197812eb422f952b9fb7b95feb86149 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Thu, 21 Oct 2021 17:43:01 +0300 Subject: [PATCH] Refactored for clarity --- .../app/features/form/FormEditTextItem.kt | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt b/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt index e23a076485..93973c1bdf 100644 --- a/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt +++ b/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt @@ -130,26 +130,25 @@ abstract class FormEditTextItem : VectorEpoxyModel() { * especially when we want to use a single line, we set the InputType to InputType.TYPE_CLASS_TEXT * while the default for the EditText is InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE */ - private fun configureInputType(holder: Holder) = - inputType?.let { - holder.textInputEditText.setRawInputType(it) - } ?: when (singleLine) { - true -> holder.textInputEditText.setRawInputType(InputType.TYPE_CLASS_TEXT) - false -> holder.textInputEditText.setRawInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) + private fun configureInputType(holder: Holder) = holder.textInputEditText.setRawInputType( + inputType ?: when (singleLine) { + true -> InputType.TYPE_CLASS_TEXT + false -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE } + ) /** - * Configure the imeOptions of the EditText, when imeOptions are not defined by user + * Configure the imeOptions of the EditText, when imeOptions are not defined by the developer * EditorInfo.IME_ACTION_NEXT will be used for singleLine EditTexts to disable "new line" * while EditorInfo.IME_ACTION_NONE will be used for all the other cases */ - private fun configureImeOptions(holder: Holder) = - imeOptions?.let { - holder.textInputEditText.imeOptions = it - } ?: when (singleLine) { - true -> holder.textInputEditText.imeOptions = EditorInfo.IME_ACTION_NEXT - false -> holder.textInputEditText.imeOptions = EditorInfo.IME_ACTION_NONE - } + private fun configureImeOptions(holder: Holder) { + holder.textInputEditText.imeOptions = + imeOptions ?: when (singleLine) { + true -> EditorInfo.IME_ACTION_NEXT + false -> EditorInfo.IME_ACTION_NONE + } + } override fun shouldSaveViewState(): Boolean { return false