Prevent crash

This commit is contained in:
M66B 2021-06-13 17:16:18 +02:00
parent 0ce2da94af
commit f3780c0f82
1 changed files with 23 additions and 0 deletions

View File

@ -63,6 +63,29 @@ public class EditTextPlain extends FixedEditText {
public boolean commitText(CharSequence text, int newCursorPosition) {
return super.commitText(text.toString(), newCursorPosition);
}
@Override
public CharSequence getSelectedText(int flags) {
try {
return super.getSelectedText(flags);
} catch (Throwable ex) {
Log.w(ex);
return null;
/*
java.lang.IndexOutOfBoundsException: getChars (-1 ... 52) starts before 0
at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1314)
at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:1191)
at android.text.TextUtils.getChars(TextUtils.java:100)
at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:67)
at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:1183)
at android.view.inputmethod.BaseInputConnection.getSelectedText(BaseInputConnection.java:528)
at android.view.inputmethod.InputConnectionWrapper.getSelectedText(InputConnectionWrapper.java:94)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:286)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:85)
at android.os.Handler.dispatchMessage(Handler.java:106)
*/
}
}
};
}