add a text change listener to the dialpad input value

This commit is contained in:
tibbi 2018-09-24 12:05:50 +02:00
parent 47405d8775
commit 6159e55183
2 changed files with 19 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.commons.helpers.isLollipopPlus
import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.extensions.afterTextChanged
import com.simplemobiletools.contacts.extensions.config
import kotlinx.android.synthetic.main.activity_dialpad.*
@ -31,6 +32,7 @@ class DialpadActivity : SimpleActivity() {
dialpad_hashtag.setOnClickListener { dialpadPressed("#") }
dialpad_clear_char.setOnClickListener { clearChar() }
dialpad_clear_char.setOnLongClickListener { clearInput(); true }
dialpad_input.afterTextChanged { dialpadValueChanged(it) }
disableKeyboardPopping()
}
@ -77,4 +79,8 @@ class DialpadActivity : SimpleActivity() {
dialpad_input.inputType = InputType.TYPE_NULL
}
}
private fun dialpadValueChanged(text: String) {
}
}

View File

@ -0,0 +1,13 @@
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())
})