title: Manipulate or capture EditText input efficiently
body: <h2><strong>What i'm trying to achieve</strong></h2>
  
  <p>I want to convert every char the user inputs to another char and display it in the <code>EditText</code>.</p>
  
  <h2><strong>What i've done</strong></h2>
  
  <p>My first approach is implemented using a <a href="https://developer.android.com/reference/android/text/TextWatcher.html" rel="nofollow noreferrer"><code>TextWatcher</code></a>.</p>
  
  <pre><code>     private val textWatcher2 = object : TextWatcher {
          private var byUser = true
  
          override fun afterTextChanged(s: Editable?) {
  
  
          }
  
          override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
  
          }
  
          override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
              if (!byUser) return
  
              byUser = false
  
              val t = this@ManipulatingEditText.text.toString()
              val m = convert(t.last())
              val s = t.substring(0, t.length - 1) + m
              this@ManipulatingEditText.setText("")
              this@ManipulatingEditText.setText(s)
              this@ManipulatingEditText.setSelection(this@ManipulatingEditText.text!!.length)
  
              byUser = true
          }
      }
  
      /*This is just an mock of my real implementation. But the same delay occurs*/
      fun convert(c: Char) : String {
          return c.toString()
      }
  </code></pre>
  
  <p>This is working: Every new input char is converted via the convert(Char) function. Unfortunately this solution <strong>is incredibly slow</strong> and <strong>inefficient</strong>. There is a short delay after each input and you can't type fast.</p>
  
  <p>This solution is not suitable for a production app. But i have not found another solution yet (Debouncing or deffering via RxJava doesn't work because some chars get skipped or race conditions apply) that works better.</p>
  
  <p>Any ideas, solutions or help is appreciated.</p>