Contacts/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/EditText.kt

13 lines
513 B
Kotlin

package com.simplemobiletools.contacts.extensions
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
fun EditText.afterTextChanged(callback: (String) -> Unit) = addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
override fun afterTextChanged(text: Editable) = callback(text.toString())
})