mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Some code reorganization.
Use the same local variable inside both branches of an if. Change-Id: I61f7d506d984f3723ec90604416d1875dd97cd8c
This commit is contained in:
parent
b5eeb724fc
commit
bd4ba23d2b
@ -391,6 +391,7 @@ public class Suggest implements Dictionary.WordCallback {
|
||||
StringUtils.removeDupes(mSuggestions);
|
||||
|
||||
final SuggestedWords.Builder builder;
|
||||
final ArrayList<SuggestedWords.SuggestedWordInfo> scoreInfoList;
|
||||
if (DBG) {
|
||||
// TODO: this doesn't take into account the fact that removing dupes from mSuggestions
|
||||
// may have made mScores[] and mSuggestions out of sync.
|
||||
@ -399,8 +400,7 @@ public class Suggest implements Dictionary.WordCallback {
|
||||
double normalizedScore = BinaryDictionary.calcNormalizedScore(
|
||||
typedWord, autoCorrectionSuggestion.toString(),
|
||||
autoCorrectionSuggestionScore);
|
||||
ArrayList<SuggestedWords.SuggestedWordInfo> scoreInfoList =
|
||||
new ArrayList<SuggestedWords.SuggestedWordInfo>();
|
||||
scoreInfoList = new ArrayList<SuggestedWords.SuggestedWordInfo>();
|
||||
scoreInfoList.add(new SuggestedWords.SuggestedWordInfo(autoCorrectionSuggestion, "+",
|
||||
false));
|
||||
final int suggestionsSize = mSuggestions.size();
|
||||
@ -424,13 +424,8 @@ public class Suggest implements Dictionary.WordCallback {
|
||||
scoreInfoList.add(new SuggestedWords.SuggestedWordInfo(mSuggestions.get(i),
|
||||
"--", false));
|
||||
}
|
||||
builder = new SuggestedWords.Builder(scoreInfoList, allowsToBeAutoCorrected,
|
||||
false /* isPunctuationSuggestions */);
|
||||
} else {
|
||||
builder = new SuggestedWords.Builder(
|
||||
SuggestedWords.Builder.getFromCharSequenceList(mSuggestions),
|
||||
allowsToBeAutoCorrected,
|
||||
false /* isPunctuationSuggestions */);
|
||||
scoreInfoList = SuggestedWords.Builder.getFromCharSequenceList(mSuggestions);
|
||||
}
|
||||
|
||||
boolean autoCorrectionAvailable = hasAutoCorrection;
|
||||
@ -440,6 +435,8 @@ public class Suggest implements Dictionary.WordCallback {
|
||||
}
|
||||
// Don't auto-correct words with multiple capital letter
|
||||
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
|
||||
builder = new SuggestedWords.Builder(scoreInfoList, allowsToBeAutoCorrected,
|
||||
false /* isPunctuationSuggestions */);
|
||||
builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion(
|
||||
autoCorrectionAvailable);
|
||||
if (allowsToBeAutoCorrected && builder.size() > 1 && mAutoCorrectionThreshold > 0
|
||||
|
@ -88,7 +88,7 @@ public class SuggestedWords {
|
||||
mIsPunctuationSuggestions = isPunctuationSuggestions;
|
||||
}
|
||||
|
||||
public static List<SuggestedWordInfo> getFromCharSequenceList(
|
||||
public static ArrayList<SuggestedWordInfo> getFromCharSequenceList(
|
||||
final List<CharSequence> wordList) {
|
||||
final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>();
|
||||
for (CharSequence word : wordList) {
|
||||
|
Loading…
Reference in New Issue
Block a user