diff options
author | 2012-07-09 17:39:34 +0900 | |
---|---|---|
committer | 2012-07-10 19:19:43 +0900 | |
commit | 0f57bdc0e5d1ecebc00bff36d5ce544f343b5589 (patch) | |
tree | f087270e4c74e07f01085a9fb9fc33d9c2dd14c0 /java | |
parent | 4e42e378fa41cfacf2c393a9428d75f6c6a0d7a8 (diff) | |
download | latinime-0f57bdc0e5d1ecebc00bff36d5ce544f343b5589.tar.gz latinime-0f57bdc0e5d1ecebc00bff36d5ce544f343b5589.tar.xz latinime-0f57bdc0e5d1ecebc00bff36d5ce544f343b5589.zip |
Factorize code (A87)
Why was this copy-pasted :(
Change-Id: I6a537c56425ad039d7301a5fe1e0485784f07914
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/ExpandableDictionary.java | 20 |
1 files changed, 7 insertions, 13 deletions
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<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, |