title: IndexOutOfBoundsException setSpan (0 ... 1) ends beyond length 0
body: <p>I am using this library for material editText with label:
  <a href="https://github.com/rey5137/Material/wiki/Text-Field" rel="noreferrer">https://github.com/rey5137/Material/wiki/Text-Field</a>
  nice library :)</p>
  
  <p>but...</p>
  
  <p>i am using next code to check are entered symbols correct:</p>
  
  <pre><code>private boolean hasCorrectSymbols(String input){
          String tre = "[A-Za-z0-9\\@\\#\\$\\%\\&amp;\\*\\(\\)\\-\\+\\_\\;\\:\\?\\.\\,\\!]+$";
          if (input.matches(tre)){
              return true;
          }
          return false;
      }
  </code></pre>
  
  <p>for checking correct symbols I am using textWatcher:</p>
  
  <pre><code>mEditPass.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
  
              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {
                  if (s.length() == 1 &amp;&amp; !loginPassHasCorrectSymbols(s.toString())){
                      mEditPass.getText().clear();
                      String mess = getString(R.string.toast_login_useLatin);
                      showToastMessage(mess);
                  } else if (s.length() &gt;1 &amp;&amp; !loginPassHasCorrectSymbols(s.toString())) {
                      String mess = getString(R.string.toast_login_useLatin);
                      showToastMessage(mess);
                      String text = s.toString();
                      text = text.substring(0, start);
                      mEditPass.setText(text);
                      mEditPass.setSelection(start);
                  }
              }
  
              @Override
              public void afterTextChanged(Editable s) {}
          });
  </code></pre>
  
  <p>if first symbol is correct and the second one for example is wrong - system will cut last entered (wrong) symbol and set cursor to the last text position, but if the first symbol is prohibited symbol - it will crash with this error:</p>
  
  <pre><code>java.lang.IndexOutOfBoundsException: setSpan (0 ... 1) ends beyond length 0
              at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1016)
              at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:592)
              at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:588)
              at android.text.method.PasswordTransformationMethod.onTextChanged(PasswordTransformationMethod.java:108)
              at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:962)
              at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:496)
              at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435)
              at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30)
              at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:683)
              at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:198)
              at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:183)
              at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:279)
              at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5097)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
              at dalvik.system.NativeStart.main(Native Method) 
  </code></pre>
  
  <p>Any ideas why it happen? And how to fix this??</p>