From 5e4e05afd2825bf7acb594fef5e7bd21c751dd63 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Sat, 18 Jun 2011 13:33:48 +0900 Subject: [PATCH] Fix NPE Bug: 4686479 Change-Id: I0b8a32d0f9bcebe55eebecd38dc5e69198e94378 --- .../inputmethod/keyboard/KeyboardSwitcher.java | 12 ++++++++---- java/src/com/android/inputmethod/latin/LatinIME.java | 10 ++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 50c61ffae..af2220811 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -782,11 +782,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } public void onAutoCorrectionStateChanged(boolean isAutoCorrection) { - if (isAutoCorrection != mIsAutoCorrectionActive) { - LatinKeyboardView keyboardView = getKeyboardView(); + if (mIsAutoCorrectionActive != isAutoCorrection) { mIsAutoCorrectionActive = isAutoCorrection; - keyboardView.invalidateKey(((LatinKeyboard) keyboardView.getKeyboard()) - .onAutoCorrectionStateChanged(isAutoCorrection)); + final LatinKeyboard keyboard = getLatinKeyboard(); + if (keyboard != null && keyboard.needsAutoCorrectionSpacebarLed()) { + final Key invalidatedKey = keyboard.onAutoCorrectionStateChanged(isAutoCorrection); + final LatinKeyboardView keyboardView = getKeyboardView(); + if (keyboardView != null) + keyboardView.invalidateKey(invalidatedKey); + } } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index fc01d3976..7446aff9e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1459,16 +1459,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } public void setSuggestions(SuggestedWords words) { -// if (mVoiceProxy.getAndResetIsShowingHint()) { -// setCandidatesView(mCandidateViewContainer); -// } - if (mCandidateView != null) { mCandidateView.setSuggestions(words); - if (mKeyboardSwitcher.getLatinKeyboard().needsAutoCorrectionSpacebarLed()) { - mKeyboardSwitcher.onAutoCorrectionStateChanged( - words.hasWordAboveAutoCorrectionScoreThreshold()); - } + mKeyboardSwitcher.onAutoCorrectionStateChanged( + words.hasWordAboveAutoCorrectionScoreThreshold()); } }