Fix an NPE.

Change-Id: Ie5ab5cc716ef1211eb9ad76baa0467455e1f1a71
This commit is contained in:
Jean Chalard 2014-11-20 14:35:39 +09:00
parent 1d80cb2301
commit a94733cbca
2 changed files with 8 additions and 5 deletions

View file

@ -152,12 +152,16 @@ public final class AccessibilityUtils {
* will occur when a key is typed. * will occur when a key is typed.
* *
* @param suggestedWords the list of suggested auto-correction words * @param suggestedWords the list of suggested auto-correction words
* @param typedWord the currently typed word
*/ */
public void setAutoCorrection(final SuggestedWords suggestedWords, final String typedWord) { public void setAutoCorrection(final SuggestedWords suggestedWords) {
if (suggestedWords.mWillAutoCorrect) { if (suggestedWords.mWillAutoCorrect) {
mAutoCorrectionWord = suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION); mAutoCorrectionWord = suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION);
mTypedWord = typedWord; final SuggestedWords.SuggestedWordInfo typedWordInfo = suggestedWords.mTypedWordInfo;
if (null == typedWordInfo) {
mTypedWord = null;
} else {
mTypedWord = typedWordInfo.mWord;
}
} else { } else {
mAutoCorrectionWord = null; mAutoCorrectionWord = null;
mTypedWord = null; mTypedWord = null;

View file

@ -1637,8 +1637,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
// Cache the auto-correction in accessibility code so we can speak it if the user // Cache the auto-correction in accessibility code so we can speak it if the user
// touches a key that will insert it. // touches a key that will insert it.
AccessibilityUtils.getInstance().setAutoCorrection(suggestedWords, AccessibilityUtils.getInstance().setAutoCorrection(suggestedWords);
suggestedWords.mTypedWordInfo.mWord);
} }
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener} // Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}