Fixed that validation label still got displayed even though there's no error or hint to display anymore

This commit is contained in:
dankito 2020-11-06 02:52:33 +01:00
parent 30f564a886
commit 873a9a537e
2 changed files with 8 additions and 3 deletions

View File

@ -49,7 +49,7 @@ ext {
fileChooserDialogVersion = "1.3.0-androidx"
androidUtilsVersion = '1.1.1-SNAPSHOT'
androidUtilsVersion = '1.1.2'
fastAdapterVersion = "5.2.4"

View File

@ -39,6 +39,7 @@ import net.dankito.utils.multiplatform.toBigDecimal
import net.dankito.utils.android.extensions.asActivity
import net.dankito.utils.android.extensions.getDimension
import net.dankito.utils.android.extensions.getResourceIdentifier
import net.dankito.utils.android.extensions.setVisibility
import java.math.BigDecimal
import java.text.DecimalFormatSymbols
import java.util.*
@ -478,14 +479,18 @@ open class TransferMoneyDialog : DialogFragment() {
}
}
val showHintOrError = validationResult.validationError != null || validationResult.validationHint != null
val textInputErrorLayout = textInputLayout.getResourceIdentifier("textinput_error", "id")?.let { textInputErrorId -> textInputLayout.findViewById<View>(textInputErrorId)?.parent?.parent as? View }
textInputErrorLayout?.setVisibility(showHintOrError)
textInputLayout.error = validationResult.validationError
if (validationResult.validationError == null) { // don't overwrite error text
textInputLayout.helperText = validationResult.validationHint
}
(textInputLayout.layoutParams as? ViewGroup.MarginLayoutParams)?.let { params ->
val isShowingHintOrError = validationResult.validationError != null || validationResult.validationHint != null
params.bottomMargin = if (isShowingHintOrError == false || textInputLayout == lytReference) 0
params.bottomMargin = if (showHintOrError == false || textInputLayout == lytReference) 0
else context!!.getDimension(R.dimen.dialog_transfer_money_input_fields_bottom_margin_when_displaying_validation_label)
}
}