Stanislav Shamilov
09/12/2019, 9:51 PMfun EditText.textChanges(): Flow<String> = callbackFlow {
val textWatcher = textWatcher(afterText = {
this.channel.offer(it ?: "")
})
this@textChanges.addTextChangedListener(textWatcher)
awaitClose { this@textChanges.removeTextChangedListener(textWatcher) }
}
private fun textWatcher(
beforeText: (String?) -> Unit = {},
onText: (String?) -> Unit = {},
afterText: (String?) -> Unit = {}
): TextWatcher {
return object : TextWatcher {
override fun afterTextChanged(s: Editable?) = afterText(s?.toString())
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = beforeText(s?.toString())
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = onText(s?.toString())
}
}
Kotlin version: 1.3.50
Coroutines version: 1.3.0
IDE: Android Studio 3.5
I have two questions:
1. Why does this warning show up?
2. What does this warning stand for?
Thanks in advance!