Remove a now-useless flag.

This has been moved to the SuggestedWords object and is now
represented by a single flag instead of a flag in each suggestion.

Change-Id: I6e9a7cff5a7701de7e61b4de13baac25c9a87b1b
This commit is contained in:
Jean Chalard 2012-03-15 14:21:02 +09:00
parent 4f6cf258fe
commit 3187ba5dfe
2 changed files with 8 additions and 17 deletions

View file

@ -429,7 +429,7 @@ public class Suggest implements Dictionary.WordCallback {
final int suggestionsSize = suggestions.size(); final int suggestionsSize = suggestions.size();
final ArrayList<SuggestedWordInfo> suggestionsList = final ArrayList<SuggestedWordInfo> suggestionsList =
new ArrayList<SuggestedWordInfo>(suggestionsSize); new ArrayList<SuggestedWordInfo>(suggestionsSize);
suggestionsList.add(new SuggestedWordInfo(autoCorrectionSuggestion, "+", false)); suggestionsList.add(new SuggestedWordInfo(autoCorrectionSuggestion, "+"));
// Note: i here is the index in mScores[], but the index in mSuggestions is one more // Note: i here is the index in mScores[], but the index in mSuggestions is one more
// than i because we added the typed word to mSuggestions without touching mScores. // than i because we added the typed word to mSuggestions without touching mScores.
for (int i = 0; i < scores.length && i < suggestionsSize - 1; ++i) { for (int i = 0; i < scores.length && i < suggestionsSize - 1; ++i) {
@ -440,11 +440,10 @@ public class Suggest implements Dictionary.WordCallback {
} else { } else {
scoreInfoString = Integer.toString(scores[i]); scoreInfoString = Integer.toString(scores[i]);
} }
suggestionsList.add(new SuggestedWordInfo(suggestions.get(i + 1), suggestionsList.add(new SuggestedWordInfo(suggestions.get(i + 1), scoreInfoString));
scoreInfoString, false));
} }
for (int i = scores.length; i < suggestionsSize; ++i) { for (int i = scores.length; i < suggestionsSize; ++i) {
suggestionsList.add(new SuggestedWordInfo(suggestions.get(i), "--", false)); suggestionsList.add(new SuggestedWordInfo(suggestions.get(i), "--"));
} }
return suggestionsList; return suggestionsList;
} }

View file

@ -85,7 +85,7 @@ public class SuggestedWords {
final List<CharSequence> wordList) { final List<CharSequence> wordList) {
final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>(); final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>();
for (CharSequence word : wordList) { for (CharSequence word : wordList) {
if (null != word) result.add(new SuggestedWordInfo(word, null, false)); if (null != word) result.add(new SuggestedWordInfo(word, null));
} }
return result; return result;
} }
@ -94,7 +94,7 @@ public class SuggestedWords {
final CompletionInfo[] infos) { final CompletionInfo[] infos) {
final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>(); final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>();
for (CompletionInfo info : infos) { for (CompletionInfo info : infos) {
if (null != info) result.add(new SuggestedWordInfo(info.getText(), null, false)); if (null != info) result.add(new SuggestedWordInfo(info.getText(), null));
} }
return result; return result;
} }
@ -105,14 +105,14 @@ public class SuggestedWords {
final CharSequence typedWord, final SuggestedWords previousSuggestions) { final CharSequence typedWord, final SuggestedWords previousSuggestions) {
final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<SuggestedWordInfo>(); final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<SuggestedWordInfo>();
final HashSet<String> alreadySeen = new HashSet<String>(); final HashSet<String> alreadySeen = new HashSet<String>();
suggestionsList.add(new SuggestedWordInfo(typedWord, null, false)); suggestionsList.add(new SuggestedWordInfo(typedWord, null));
alreadySeen.add(typedWord.toString()); alreadySeen.add(typedWord.toString());
final int previousSize = previousSuggestions.size(); final int previousSize = previousSuggestions.size();
for (int pos = 1; pos < previousSize; pos++) { for (int pos = 1; pos < previousSize; pos++) {
final String prevWord = previousSuggestions.getWord(pos).toString(); final String prevWord = previousSuggestions.getWord(pos).toString();
// Filter out duplicate suggestion. // Filter out duplicate suggestion.
if (!alreadySeen.contains(prevWord)) { if (!alreadySeen.contains(prevWord)) {
suggestionsList.add(new SuggestedWordInfo(prevWord, null, true)); suggestionsList.add(new SuggestedWordInfo(prevWord, null));
alreadySeen.add(prevWord); alreadySeen.add(prevWord);
} }
} }
@ -122,19 +122,15 @@ public class SuggestedWords {
public static class SuggestedWordInfo { public static class SuggestedWordInfo {
public final CharSequence mWord; public final CharSequence mWord;
private final CharSequence mDebugString; private final CharSequence mDebugString;
private final boolean mPreviousSuggestedWord;
public SuggestedWordInfo(final CharSequence word) { public SuggestedWordInfo(final CharSequence word) {
mWord = word; mWord = word;
mDebugString = ""; mDebugString = "";
mPreviousSuggestedWord = false;
} }
public SuggestedWordInfo(final CharSequence word, final CharSequence debugString, public SuggestedWordInfo(final CharSequence word, final CharSequence debugString) {
final boolean previousSuggestedWord) {
mWord = word; mWord = word;
mDebugString = debugString; mDebugString = debugString;
mPreviousSuggestedWord = previousSuggestedWord;
} }
public String getDebugString() { public String getDebugString() {
@ -145,10 +141,6 @@ public class SuggestedWords {
} }
} }
public boolean isObsoleteSuggestedWord () {
return mPreviousSuggestedWord;
}
@Override @Override
public String toString() { public String toString() {
if (TextUtils.isEmpty(mDebugString)) { if (TextUtils.isEmpty(mDebugString)) {