aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-06-19 16:37:52 +0900
committerJean Chalard <jchalard@google.com>2014-06-27 12:59:44 +0900
commitee5c032557ab3629babbacc1e52f1a6d1cd8d844 (patch)
tree1cf957a10b9b349c421ebed34c3de335edd90b94 /java/src/com/android/inputmethod/latin/Suggest.java
parentc152d7c19d4a9e84acaf6fffa4f51c583f191f6f (diff)
downloadlatinime-ee5c032557ab3629babbacc1e52f1a6d1cd8d844.tar.gz
latinime-ee5c032557ab3629babbacc1e52f1a6d1cd8d844.tar.xz
latinime-ee5c032557ab3629babbacc1e52f1a6d1cd8d844.zip
[CS5] Use a local var to keep the first suggestion
Bug: 13238601 Change-Id: Ida8973945e8b141d01ea9d1825b89d84f0911575
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Suggest.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 692c03a4c..e43db352d 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -126,16 +126,17 @@ public final class Suggest {
final boolean didRemoveTypedWord =
SuggestedWordInfo.removeDups(typedWord, suggestionsContainer);
+ final SuggestedWordInfo firstSuggestedWordInfo;
final String whitelistedWord;
if (suggestionsContainer.isEmpty()) {
+ firstSuggestedWordInfo = null;
whitelistedWord = null;
} else {
- final SuggestedWordInfo firstSuggestedWordInfo = suggestionsContainer.get(0);
- final String firstSuggestion = firstSuggestedWordInfo.mWord;
+ firstSuggestedWordInfo = suggestionsContainer.get(0);
if (!firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) {
whitelistedWord = null;
} 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 word *would* have been auto-corrected.
if (!isCorrectionEnabled || !allowsToBeAutoCorrected || isPrediction
- || suggestionResults.isEmpty() || wordComposer.hasDigits()
+ || null == firstSuggestedWordInfo || wordComposer.hasDigits()
|| wordComposer.isMostlyCaps() || wordComposer.isResumed()
|| !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
// 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
@@ -166,7 +167,7 @@ public final class Suggest {
hasAutoCorrection = false;
} else {
hasAutoCorrection = AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold(
- suggestionResults.first(), consideredWord, mAutoCorrectionThreshold);
+ firstSuggestedWordInfo, consideredWord, mAutoCorrectionThreshold);
}
if (!TextUtils.isEmpty(typedWord)) {