am ee5c0325: [CS5] Use a local var to keep the first suggestion

* commit 'ee5c032557ab3629babbacc1e52f1a6d1cd8d844':
  [CS5] Use a local var to keep the first suggestion
main
Jean Chalard 2014-06-27 04:08:48 +00:00 committed by Android Git Automerger
commit bf589d352f
1 changed files with 7 additions and 6 deletions

View File

@ -126,16 +126,17 @@ public final class Suggest {
final boolean didRemoveTypedWord = final boolean didRemoveTypedWord =
SuggestedWordInfo.removeDups(typedWord, suggestionsContainer); SuggestedWordInfo.removeDups(typedWord, suggestionsContainer);
final SuggestedWordInfo firstSuggestedWordInfo;
final String whitelistedWord; final String whitelistedWord;
if (suggestionsContainer.isEmpty()) { if (suggestionsContainer.isEmpty()) {
firstSuggestedWordInfo = null;
whitelistedWord = null; whitelistedWord = null;
} else { } else {
final SuggestedWordInfo firstSuggestedWordInfo = suggestionsContainer.get(0); firstSuggestedWordInfo = suggestionsContainer.get(0);
final String firstSuggestion = firstSuggestedWordInfo.mWord;
if (!firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) { if (!firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) {
whitelistedWord = null; whitelistedWord = null;
} else { } else {
whitelistedWord = firstSuggestion; whitelistedWord = firstSuggestedWordInfo.mWord;
} }
} }
@ -151,10 +152,10 @@ public final class Suggest {
// the current settings. It may also be useful to know, when the setting is off, whether // the current settings. It may also be useful to know, when the setting is off, whether
// the word *would* have been auto-corrected. // the word *would* have been auto-corrected.
if (!isCorrectionEnabled || !allowsToBeAutoCorrected || isPrediction if (!isCorrectionEnabled || !allowsToBeAutoCorrected || isPrediction
|| suggestionResults.isEmpty() || wordComposer.hasDigits() || null == firstSuggestedWordInfo || wordComposer.hasDigits()
|| wordComposer.isMostlyCaps() || wordComposer.isResumed() || wordComposer.isMostlyCaps() || wordComposer.isResumed()
|| !mDictionaryFacilitator.hasInitializedMainDictionary() || !mDictionaryFacilitator.hasInitializedMainDictionary()
|| suggestionResults.first().isKindOf(SuggestedWordInfo.KIND_SHORTCUT)) { || firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_SHORTCUT)) {
// If we don't have a main dictionary, we never want to auto-correct. The reason for // If we don't have a main dictionary, we never want to auto-correct. The reason for
// this is, the user may have a contact whose name happens to match a valid word in // this is, the user may have a contact whose name happens to match a valid word in
// their language, and it will unexpectedly auto-correct. For example, if the user // their language, and it will unexpectedly auto-correct. For example, if the user
@ -166,7 +167,7 @@ public final class Suggest {
hasAutoCorrection = false; hasAutoCorrection = false;
} else { } else {
hasAutoCorrection = AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold( hasAutoCorrection = AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold(
suggestionResults.first(), consideredWord, mAutoCorrectionThreshold); firstSuggestedWordInfo, consideredWord, mAutoCorrectionThreshold);
} }
if (!TextUtils.isEmpty(typedWord)) { if (!TextUtils.isEmpty(typedWord)) {