Inline a method (A14)

The new code is worse than the old one, but this is a necessary
step to make things prettier.

Change-Id: If6e8a139bb85e6920c749743c78792a22a8acb45
This commit is contained in:
Jean Chalard 2012-06-28 16:54:53 +09:00
parent 1333579b4b
commit 074c90af98
2 changed files with 14 additions and 23 deletions

View File

@ -31,22 +31,6 @@ public class AutoCorrection {
// Purely static class: can't instantiate.
}
public static CharSequence computeAutoCorrectionWord(
final ConcurrentHashMap<String, Dictionary> dictionaries,
final WordComposer wordComposer, SuggestedWordInfo suggestion,
final CharSequence consideredWord, final float autoCorrectionThreshold,
final CharSequence whitelistedWord) {
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
return whitelistedWord;
} else if (shouldAutoCorrectToSelf(dictionaries, consideredWord)) {
return consideredWord;
} else if (hasAutoCorrectionForBinaryDictionary(suggestion,
consideredWord, autoCorrectionThreshold)) {
return suggestion.mWord;
}
return null;
}
public static boolean isValidWord(final ConcurrentHashMap<String, Dictionary> dictionaries,
CharSequence word, boolean ignoreCase) {
if (TextUtils.isEmpty(word)) {
@ -104,18 +88,18 @@ public class AutoCorrection {
return !isValidWord(dictionaries, word, ignoreCase);
}
private static boolean hasAutoCorrectionForWhitelistedWord(CharSequence whiteListedWord) {
static public boolean hasAutoCorrectionForWhitelistedWord(CharSequence whiteListedWord) {
return whiteListedWord != null;
}
private static boolean shouldAutoCorrectToSelf(
public static boolean shouldAutoCorrectToSelf(
final ConcurrentHashMap<String, Dictionary> dictionaries,
final CharSequence consideredWord) {
if (TextUtils.isEmpty(consideredWord)) return false;
return !allowsToBeAutoCorrected(dictionaries, consideredWord, false);
}
private static boolean hasAutoCorrectionForBinaryDictionary(SuggestedWordInfo suggestion,
public static boolean hasAutoCorrectionForBinaryDictionary(SuggestedWordInfo suggestion,
CharSequence consideredWord, float autoCorrectionThreshold) {
if (null != suggestion) {
//final int autoCorrectionSuggestionScore = sortedScores[0];

View File

@ -230,10 +230,17 @@ public class Suggest {
if (isCorrectionEnabled) {
final SuggestedWordInfo bestSuggestion = suggestionsSet.isEmpty()
? null : suggestionsSet.first();
final CharSequence autoCorrection =
AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer,
bestSuggestion, consideredWord, mAutoCorrectionThreshold,
whitelistedWord);
final CharSequence autoCorrection;
if (AutoCorrection.hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
autoCorrection = whitelistedWord;
} else if (AutoCorrection.shouldAutoCorrectToSelf(mDictionaries, consideredWord)) {
autoCorrection = consideredWord;
} else if (AutoCorrection.hasAutoCorrectionForBinaryDictionary(bestSuggestion,
consideredWord, mAutoCorrectionThreshold)) {
autoCorrection = bestSuggestion.mWord;
} else {
autoCorrection = null;
}
hasAutoCorrection = (null != autoCorrection);
} else {
hasAutoCorrection = false;