Skip to content

Instantly share code, notes, and snippets.

View shahharshil0's full-sized avatar

Harshil Shah shahharshil0

View GitHub Profile
fun TextInputEditText.isNotNullOrEmpty(errorString: String): Boolean {
val textInputLayout = this.parent.parent as TextInputLayout
textInputLayout.errorIconDrawable = null
this.onChange { textInputLayout.error = null }
return if (this.text.toString().trim().isEmpty()) {
textInputLayout.error = errorString
false
} else {
true
if(TextInputEditText.isNotNullOrEmpty("This field is required") and
(TextInputEditText.isNotNullOrEmpty("This field is required")) {
//this will be executed only if the TextInputEditText contains
// some text else error will be displayed by the extension function itself
}