diff options
author | 2012-08-05 19:25:20 -0700 | |
---|---|---|
committer | 2012-08-05 19:25:20 -0700 | |
commit | 6b4cada7b2be00bda7e3d0f9be6b76e714404019 (patch) | |
tree | 12704c9d6d1cc75f26b067b4d9f454d19e936c43 /java/src | |
parent | 838e6c1e5b734ed2d7b68a082f61b723d1aa35a2 (diff) | |
parent | 2687b667a7edb889fd2704380fee45f848da6626 (diff) | |
download | latinime-6b4cada7b2be00bda7e3d0f9be6b76e714404019.tar.gz latinime-6b4cada7b2be00bda7e3d0f9be6b76e714404019.tar.xz latinime-6b4cada7b2be00bda7e3d0f9be6b76e714404019.zip |
am 2687b667: am 4e9e6cd1: Fix IllegalStateException of KeyDetector
* commit '2687b667a7edb889fd2704380fee45f848da6626':
Fix IllegalStateException of KeyDetector
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyDetector.java | 5 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java index a3b7776b3..97d88af4a 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java @@ -37,8 +37,9 @@ public class KeyDetector { } public void setKeyboard(Keyboard keyboard, float correctionX, float correctionY) { - if (keyboard == null) + if (keyboard == null) { throw new NullPointerException(); + } mCorrectionX = (int)correctionX; mCorrectionY = (int)correctionY; mKeyboard = keyboard; @@ -58,8 +59,6 @@ public class KeyDetector { } public Keyboard getKeyboard() { - if (mKeyboard == null) - throw new IllegalStateException("keyboard isn't set"); return mKeyboard; } diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java index cd4e3001e..a183546dd 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java @@ -39,7 +39,11 @@ public class MoreKeysDetector extends KeyDetector { Key nearestKey = null; int nearestDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare; - for (final Key key : getKeyboard().mKeys) { + final Keyboard keyboard = getKeyboard(); + if (keyboard == null) { + throw new NullPointerException("Keyboard isn't set"); + } + for (final Key key : keyboard.mKeys) { final int dist = key.squaredDistanceToEdge(touchX, touchY); if (dist < nearestDist) { nearestKey = key; |