Merge "Some code simplification"

main
Jean Chalard 2012-03-14 18:47:16 -07:00 committed by Android (Google) Code Review
commit 53d57ad6d3
1 changed files with 6 additions and 6 deletions

View File

@ -22,6 +22,7 @@ import android.util.Log;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -392,15 +393,15 @@ public class Suggest implements Dictionary.WordCallback {
mSuggestions.add(0, typedWord); mSuggestions.add(0, typedWord);
StringUtils.removeDupes(mSuggestions); StringUtils.removeDupes(mSuggestions);
final ArrayList<SuggestedWords.SuggestedWordInfo> suggestionsList; final ArrayList<SuggestedWordInfo> suggestionsList;
if (DBG) { if (DBG) {
// TODO: this doesn't take into account the fact that removing dupes from mSuggestions // TODO: this doesn't take into account the fact that removing dupes from mSuggestions
// may have made mScores[] and mSuggestions out of sync. // may have made mScores[] and mSuggestions out of sync.
final CharSequence autoCorrectionSuggestion = mSuggestions.get(0); final CharSequence autoCorrectionSuggestion = mSuggestions.get(0);
double normalizedScore = BinaryDictionary.calcNormalizedScore( double normalizedScore = BinaryDictionary.calcNormalizedScore(
typedWord, autoCorrectionSuggestion.toString(), mScores[0]); typedWord, autoCorrectionSuggestion.toString(), mScores[0]);
suggestionsList = new ArrayList<SuggestedWords.SuggestedWordInfo>(); suggestionsList = new ArrayList<SuggestedWordInfo>();
suggestionsList.add(new SuggestedWords.SuggestedWordInfo(autoCorrectionSuggestion, "+", suggestionsList.add(new SuggestedWordInfo(autoCorrectionSuggestion, "+",
false)); false));
final int suggestionsSize = mSuggestions.size(); final int suggestionsSize = mSuggestions.size();
// 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
@ -413,12 +414,11 @@ public class Suggest implements Dictionary.WordCallback {
} else { } else {
scoreInfoString = Integer.toString(mScores[i]); scoreInfoString = Integer.toString(mScores[i]);
} }
suggestionsList.add(new SuggestedWords.SuggestedWordInfo(mSuggestions.get(i + 1), suggestionsList.add(new SuggestedWordInfo(mSuggestions.get(i + 1),
scoreInfoString, false)); scoreInfoString, false));
} }
for (int i = mScores.length; i < suggestionsSize; ++i) { for (int i = mScores.length; i < suggestionsSize; ++i) {
suggestionsList.add(new SuggestedWords.SuggestedWordInfo(mSuggestions.get(i), suggestionsList.add(new SuggestedWordInfo(mSuggestions.get(i), "--", false));
"--", false));
} }
} else { } else {
suggestionsList = SuggestedWords.getFromCharSequenceList(mSuggestions); suggestionsList = SuggestedWords.getFromCharSequenceList(mSuggestions);