aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-01-20 22:56:26 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-01-20 22:56:26 -0800
commit14355b786fa3d118027ed5f8eddceec32dfcb880 (patch)
tree8750b29c7c19ad99d428be227b5a7cb811d54680 /java/src/com/android/inputmethod/latin/SuggestedWords.java
parentf7b2ddb9f82487f4c2cb030abc73f2b793334b81 (diff)
parentf3df63a93a8f623e2aca5895ee749bd297b58d12 (diff)
downloadlatinime-14355b786fa3d118027ed5f8eddceec32dfcb880.tar.gz
latinime-14355b786fa3d118027ed5f8eddceec32dfcb880.tar.xz
latinime-14355b786fa3d118027ed5f8eddceec32dfcb880.zip
am f3df63a9: Update suggestions if user typed word is found in dictionary
* commit 'f3df63a93a8f623e2aca5895ee749bd297b58d12': Update suggestions if user typed word is found in dictionary
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 4407e5b31..f774ce3a5 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -20,6 +20,7 @@ import android.view.inputmethod.CompletionInfo;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
public class SuggestedWords {
@@ -128,10 +129,18 @@ public class SuggestedWords {
SuggestedWords previousSuggestions) {
mWords.clear();
mSuggestedWordInfoList.clear();
+ final HashSet<String> alreadySeen = new HashSet<String>();
addWord(typedWord, null, false);
+ alreadySeen.add(typedWord.toString());
final int previousSize = previousSuggestions.size();
- for (int pos = 1; pos < previousSize; pos++)
- addWord(previousSuggestions.getWord(pos), null, true);
+ for (int pos = 1; pos < previousSize; pos++) {
+ final String prevWord = previousSuggestions.getWord(pos).toString();
+ // Filter out duplicate suggestion.
+ if (!alreadySeen.contains(prevWord)) {
+ addWord(prevWord, null, true);
+ alreadySeen.add(prevWord);
+ }
+ }
mIsCompletions = false;
mTypedWordValid = false;
mHasMinimalSuggestion = false;