Refactored for clarity

This commit is contained in:
ariskotsomitopoulos 2021-10-21 17:43:01 +03:00
parent dc230f1c30
commit beab9ab8f1

View File

@ -130,26 +130,25 @@ abstract class FormEditTextItem : VectorEpoxyModel<FormEditTextItem.Holder>() {
* especially when we want to use a single line, we set the InputType to InputType.TYPE_CLASS_TEXT * 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 * while the default for the EditText is InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
*/ */
private fun configureInputType(holder: Holder) = private fun configureInputType(holder: Holder) = holder.textInputEditText.setRawInputType(
inputType?.let { inputType ?: when (singleLine) {
holder.textInputEditText.setRawInputType(it) true -> InputType.TYPE_CLASS_TEXT
} ?: when (singleLine) { false -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
true -> holder.textInputEditText.setRawInputType(InputType.TYPE_CLASS_TEXT)
false -> holder.textInputEditText.setRawInputType(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" * 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 * while EditorInfo.IME_ACTION_NONE will be used for all the other cases
*/ */
private fun configureImeOptions(holder: Holder) = private fun configureImeOptions(holder: Holder) {
imeOptions?.let { holder.textInputEditText.imeOptions =
holder.textInputEditText.imeOptions = it imeOptions ?: when (singleLine) {
} ?: when (singleLine) { true -> EditorInfo.IME_ACTION_NEXT
true -> holder.textInputEditText.imeOptions = EditorInfo.IME_ACTION_NEXT false -> EditorInfo.IME_ACTION_NONE
false -> holder.textInputEditText.imeOptions = EditorInfo.IME_ACTION_NONE }
} }
override fun shouldSaveViewState(): Boolean { override fun shouldSaveViewState(): Boolean {
return false return false