Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f57bdc0 authored by Jean Chalard's avatar Jean Chalard
Browse files

Factorize code (A87)

Why was this copy-pasted :(

Change-Id: I6a537c56425ad039d7301a5fe1e0485784f07914
parent 4e42e378
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
@@ -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,13 +272,11 @@ public class ExpandableDictionary extends Dictionary {
    @Override
    public ArrayList<SuggestedWordInfo> getBigrams(final WordComposer codes,
            final CharSequence previousWord) {
        if (!reloadDictionaryIfRequired()) {
        if (reloadDictionaryIfRequired()) return null;
        final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
        runBigramReverseLookUp(previousWord, suggestions);
        return suggestions;
    }
        return null;
    }

    protected final ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer codes,
            final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) {