diff options
author | 2012-10-02 22:44:57 -0700 | |
---|---|---|
committer | 2012-10-02 22:44:57 -0700 | |
commit | 5f5f7825e741b3a599490592b3955f95d2a9225f (patch) | |
tree | 55db5960a41c5d8dab2de26ac575029c280005a5 /java/src/com/android/inputmethod/latin/WordComposer.java | |
parent | 4ad4ff618f5102148d73e3c04d809942bcf16f86 (diff) | |
parent | 4d009dbc514cd77eb22e4162e4ae7ea852e1b77e (diff) | |
download | latinime-5f5f7825e741b3a599490592b3955f95d2a9225f.tar.gz latinime-5f5f7825e741b3a599490592b3955f95d2a9225f.tar.xz latinime-5f5f7825e741b3a599490592b3955f95d2a9225f.zip |
am 4d009dbc: am ace7d128: am d445b56c: Fix possible NPE caused while monkey test
* commit '4d009dbc514cd77eb22e4162e4ae7ea852e1b77e':
Fix possible NPE caused while monkey test
Diffstat (limited to 'java/src/com/android/inputmethod/latin/WordComposer.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/WordComposer.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 8a1bbed12..da0071adc 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -177,14 +177,16 @@ public final class WordComposer { * Internal method to retrieve reasonable proximity info for a character. */ private void addKeyInfo(final int codePoint, final Keyboard keyboard) { - final Key key = keyboard.getKey(codePoint); - if (key != null) { - final int x = key.mX + key.mWidth / 2; - final int y = key.mY + key.mHeight / 2; - add(codePoint, x, y); - return; + final int x, y; + final Key key; + if (keyboard != null && (key = keyboard.getKey(codePoint)) != null) { + x = key.mX + key.mWidth / 2; + y = key.mY + key.mHeight / 2; + } else { + x = Constants.NOT_A_COORDINATE; + y = Constants.NOT_A_COORDINATE; } - add(codePoint, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); + add(codePoint, x, y); } /** @@ -195,7 +197,7 @@ public final class WordComposer { reset(); final int length = word.length(); for (int i = 0; i < length; i = Character.offsetByCodePoints(word, i, 1)) { - int codePoint = Character.codePointAt(word, i); + final int codePoint = Character.codePointAt(word, i); addKeyInfo(codePoint, keyboard); } mIsResumed = true; |