diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/SuggestedWords.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 158cc1155..616e1911b 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -195,4 +195,21 @@ public final class SuggestedWords { } } } + + // SuggestedWords is an immutable object, as much as possible. We must not just remove + // words from the member ArrayList as some other parties may expect the object to never change. + public SuggestedWords getSuggestedWordsExcludingTypedWord() { + final ArrayList<SuggestedWordInfo> newSuggestions = CollectionUtils.newArrayList(); + for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) { + final SuggestedWordInfo info = mSuggestedWordInfoList.get(i); + if (SuggestedWordInfo.KIND_TYPED != info.mKind) { + newSuggestions.add(info); + } + } + // We should never autocorrect, so we say the typed word is valid. Also, in this case, + // no auto-correction should take place hence willAutoCorrect = false. + return new SuggestedWords(newSuggestions, true /* typedWordValid */, + false /* willAutoCorrect */, mIsPunctuationSuggestions, mIsObsoleteSuggestions, + mIsPrediction); + } } |