fixed a crash when trying to add a word, but the input connection is already closed
This commit is contained in:
parent
103bb93214
commit
d37b7139c6
2 changed files with 11 additions and 0 deletions
|
|
@ -157,8 +157,15 @@ class InputFieldHelper {
|
||||||
|
|
||||||
|
|
||||||
public static String getSurroundingWord(InputConnection currentInputConnection) {
|
public static String getSurroundingWord(InputConnection currentInputConnection) {
|
||||||
|
if (currentInputConnection == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
String before = (String) currentInputConnection.getTextBeforeCursor(50, 0);
|
String before = (String) currentInputConnection.getTextBeforeCursor(50, 0);
|
||||||
String after = (String) currentInputConnection.getTextAfterCursor(50, 0);
|
String after = (String) currentInputConnection.getTextAfterCursor(50, 0);
|
||||||
|
if (before == null || after == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
Matcher beforeMatch = Pattern.compile("(\\w+)$").matcher(before);
|
Matcher beforeMatch = Pattern.compile("(\\w+)$").matcher(before);
|
||||||
Matcher afterMatch = Pattern.compile("^(\\w+)").matcher(after);
|
Matcher afterMatch = Pattern.compile("^(\\w+)").matcher(after);
|
||||||
|
|
|
||||||
|
|
@ -511,6 +511,10 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
|
|
||||||
|
|
||||||
private void showAddWord() {
|
private void showAddWord() {
|
||||||
|
if (currentInputConnection == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
currentInputConnection.finishComposingText();
|
currentInputConnection.finishComposingText();
|
||||||
clearSuggestions();
|
clearSuggestions();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue