diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java index 05f3c0d94..55a25777a 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -249,12 +249,7 @@ public class ExpandableDictionary extends Dictionary { @Override public ArrayList 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 getBigrams(final WordComposer codes, final CharSequence previousWord) { - if (!reloadDictionaryIfRequired()) { - final ArrayList suggestions = new ArrayList(); - runBigramReverseLookUp(previousWord, suggestions); - return suggestions; - } - return null; + if (reloadDictionaryIfRequired()) return null; + final ArrayList suggestions = new ArrayList(); + runBigramReverseLookUp(previousWord, suggestions); + return suggestions; } protected final ArrayList getWordsInner(final WordComposer codes,