mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Factorize code (A87)
Why was this copy-pasted :( Change-Id: I6a537c56425ad039d7301a5fe1e0485784f07914
This commit is contained in:
parent
4e42e378fa
commit
0f57bdc0e5
@ -249,12 +249,7 @@ public class ExpandableDictionary extends Dictionary {
|
||||
@Override
|
||||
public ArrayList<SuggestedWordInfo> getWords(final WordComposer codes,
|
||||
final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) {
|
||||
synchronized (mUpdatingLock) {
|
||||
// If we need to update, start off a background task
|
||||
if (mRequiresReload) startDictionaryLoadingTaskLocked();
|
||||
// Currently updating contacts, don't return any results.
|
||||
if (mUpdatingDictionary) return null;
|
||||
}
|
||||
if (reloadDictionaryIfRequired()) return null;
|
||||
if (codes.size() >= BinaryDictionary.MAX_WORD_LENGTH) {
|
||||
return null;
|
||||
}
|
||||
@ -263,12 +258,13 @@ public class ExpandableDictionary extends Dictionary {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
// This reloads the dictionary if required, and returns whether it's currently updating its
|
||||
// contents or not.
|
||||
// @VisibleForTesting
|
||||
boolean reloadDictionaryIfRequired() {
|
||||
synchronized (mUpdatingLock) {
|
||||
// If we need to update, start off a background task
|
||||
if (mRequiresReload) startDictionaryLoadingTaskLocked();
|
||||
// Currently updating contacts, don't return any results.
|
||||
return mUpdatingDictionary;
|
||||
}
|
||||
}
|
||||
@ -276,12 +272,10 @@ public class ExpandableDictionary extends Dictionary {
|
||||
@Override
|
||||
public ArrayList<SuggestedWordInfo> getBigrams(final WordComposer codes,
|
||||
final CharSequence previousWord) {
|
||||
if (!reloadDictionaryIfRequired()) {
|
||||
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
|
||||
runBigramReverseLookUp(previousWord, suggestions);
|
||||
return suggestions;
|
||||
}
|
||||
return null;
|
||||
if (reloadDictionaryIfRequired()) return null;
|
||||
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
|
||||
runBigramReverseLookUp(previousWord, suggestions);
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
protected final ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer codes,
|
||||
|
Loading…
Reference in New Issue
Block a user