aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-04-19 00:07:37 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-19 00:07:37 -0700
commitf1dde6a1bf659d182db5a2645515cc1efe74459c (patch)
tree572e191e8b63d911ee521825532660252a290877 /java/src
parent3629605b7c14b5eea498ef9588f4fef788ef454c (diff)
parent758c74fe82683aef08d93a935433c027a7bc21a7 (diff)
downloadlatinime-f1dde6a1bf659d182db5a2645515cc1efe74459c.tar.gz
latinime-f1dde6a1bf659d182db5a2645515cc1efe74459c.tar.xz
latinime-f1dde6a1bf659d182db5a2645515cc1efe74459c.zip
am 758c74fe: Merge "Fix an NPE in recorrection" into jb-mr2-dev
* commit '758c74fe82683aef08d93a935433c027a7bc21a7': Fix an NPE in recorrection
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 4b58c5dc7..16eab4bc4 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1684,7 +1684,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private SuggestedWords getSuggestedWordsGestureLocked(final InputPointers batchPointers) {
mLatinIme.mWordComposer.setBatchInputPointers(batchPointers);
final SuggestedWords suggestedWords =
- mLatinIme.getSuggestedWords(Suggest.SESSION_GESTURE);
+ mLatinIme.getSuggestedWordsOrOlderSuggestions(Suggest.SESSION_GESTURE);
final int suggestionCount = suggestedWords.size();
if (suggestionCount <= 1) {
final String mostProbableSuggestion = (suggestionCount == 0) ? null
@@ -2161,7 +2161,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
return;
}
- final SuggestedWords suggestedWords = getSuggestedWords(Suggest.SESSION_TYPING);
+ final SuggestedWords suggestedWords =
+ getSuggestedWordsOrOlderSuggestions(Suggest.SESSION_TYPING);
final String typedWord = mWordComposer.getTypedWord();
showSuggestionStrip(suggestedWords, typedWord);
}
@@ -2171,7 +2172,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
if (keyboard == null || mSuggest == null) {
return SuggestedWords.EMPTY;
}
- final String typedWord = mWordComposer.getTypedWord();
// Get the word on which we should search the bigrams. If we are composing a word, it's
// whatever is *before* the half-committed word in the buffer, hence 2; if we aren't, we
// should just skip whitespace if any, so 1.
@@ -2179,10 +2179,13 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
final String prevWord =
mConnection.getNthPreviousWord(mSettings.getCurrent().mWordSeparators,
mWordComposer.isComposingWord() ? 2 : 1);
- final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer,
- prevWord, keyboard.getProximityInfo(), mSettings.getCurrent().mCorrectionEnabled,
- sessionId);
- return maybeRetrieveOlderSuggestions(typedWord, suggestedWords);
+ return mSuggest.getSuggestedWords(mWordComposer, prevWord, keyboard.getProximityInfo(),
+ mSettings.getCurrent().mCorrectionEnabled, sessionId);
+ }
+
+ private SuggestedWords getSuggestedWordsOrOlderSuggestions(final int sessionId) {
+ return maybeRetrieveOlderSuggestions(mWordComposer.getTypedWord(),
+ getSuggestedWords(sessionId));
}
private SuggestedWords maybeRetrieveOlderSuggestions(final String typedWord,
@@ -2195,7 +2198,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// old suggestions. Also, if we are showing the "add to dictionary" hint, we need to
// revert to suggestions - although it is unclear how we can come here if it's displayed.
if (suggestedWords.size() > 1 || typedWord.length() <= 1
- || suggestedWords.mTypedWordValid
+ || suggestedWords.mTypedWordValid || null == mSuggestionStripView
|| mSuggestionStripView.isShowingAddToDictionaryHint()) {
return suggestedWords;
} else {