From 60eed92dc37e59403142ac35bdf676ae7ceac298 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 21 Jun 2012 13:31:44 +0900 Subject: [PATCH] Remove the callback argument to getWords() (A15) Bug: 6252660 Bug: 6166228 Bug: 2704000 Bug: 6225530 Change-Id: I919bf70a1213ab5d7c7a9e5715bd72a6e257148b --- .../android/inputmethod/latin/BinaryDictionary.java | 3 +-- .../src/com/android/inputmethod/latin/Dictionary.java | 8 +++----- .../inputmethod/latin/DictionaryCollection.java | 7 +++---- .../inputmethod/latin/ExpandableBinaryDictionary.java | 11 ++++------- .../inputmethod/latin/ExpandableDictionary.java | 3 +-- java/src/com/android/inputmethod/latin/Suggest.java | 5 ++--- .../SynchronouslyLoadedContactsBinaryDictionary.java | 5 ++--- .../SynchronouslyLoadedUserBinaryDictionary.java | 5 ++--- 8 files changed, 18 insertions(+), 29 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 9b950d260..5603b3fb1 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -147,8 +147,7 @@ public class BinaryDictionary extends Dictionary { // proximityInfo and/or prevWordForBigrams may not be null. @Override public ArrayList getWords(final WordComposer codes, - final CharSequence prevWordForBigrams, final WordCallback callback, - final ProximityInfo proximityInfo) { + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { final int count = getSuggestions(codes, prevWordForBigrams, proximityInfo, mOutputChars, mScores, mSpaceIndices); diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java index 55913b8eb..e999e5c61 100644 --- a/java/src/com/android/inputmethod/latin/Dictionary.java +++ b/java/src/com/android/inputmethod/latin/Dictionary.java @@ -59,17 +59,15 @@ public abstract class Dictionary { /** * Searches for words in the dictionary that match the characters in the composer. Matched - * words are added through the callback object. - * @param composer the key sequence to match + * words are returned as an ArrayList. + * @param composer the key sequence to match with coordinate info, as a WordComposer * @param prevWordForBigrams the previous word, or null if none - * @param callback the callback object to send matched words to as possible candidates * @param proximityInfo the object for key proximity. May be ignored by some implementations. * @return the list of suggestions * @see WordCallback#addWord(char[], int, int, int, int, int) */ abstract public ArrayList getWords(final WordComposer composer, - final CharSequence prevWordForBigrams, final WordCallback callback, - final ProximityInfo proximityInfo); + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo); /** * Searches for pairs in the bigram dictionary that matches the previous word and all the diff --git a/java/src/com/android/inputmethod/latin/DictionaryCollection.java b/java/src/com/android/inputmethod/latin/DictionaryCollection.java index 6b424f88f..0a2f5aa76 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryCollection.java +++ b/java/src/com/android/inputmethod/latin/DictionaryCollection.java @@ -53,19 +53,18 @@ public class DictionaryCollection extends Dictionary { @Override public ArrayList getWords(final WordComposer composer, - final CharSequence prevWordForBigrams, final WordCallback callback, - final ProximityInfo proximityInfo) { + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { final CopyOnWriteArrayList dictionaries = mDictionaries; if (dictionaries.isEmpty()) return null; // To avoid creating unnecessary objects, we get the list out of the first // dictionary and add the rest to it if not null, hence the get(0) ArrayList suggestions = dictionaries.get(0).getWords(composer, - prevWordForBigrams, callback, proximityInfo); + prevWordForBigrams, proximityInfo); if (null == suggestions) suggestions = new ArrayList(); final int length = dictionaries.size(); for (int i = 0; i < length; ++ i) { final ArrayList sugg = dictionaries.get(i).getWords(composer, - prevWordForBigrams, callback, proximityInfo); + prevWordForBigrams, proximityInfo); if (null != sugg) suggestions.addAll(sugg); } return suggestions; diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 732bc1802..4cb4c14e1 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -196,22 +196,19 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { @Override public ArrayList getWords(final WordComposer codes, - final CharSequence prevWordForBigrams, final WordCallback callback, - final ProximityInfo proximityInfo) { + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { asyncReloadDictionaryIfRequired(); - return getWordsInner(codes, prevWordForBigrams, callback, proximityInfo); + return getWordsInner(codes, prevWordForBigrams, proximityInfo); } protected final ArrayList getWordsInner(final WordComposer codes, - final CharSequence prevWordForBigrams, final WordCallback callback, - final ProximityInfo proximityInfo) { + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { // Ensure that there are no concurrent calls to getWords. If there are, do nothing and // return. if (mLocalDictionaryController.tryLock()) { try { if (mBinaryDictionary != null) { - return mBinaryDictionary.getWords(codes, prevWordForBigrams, callback, - proximityInfo); + return mBinaryDictionary.getWords(codes, prevWordForBigrams, proximityInfo); } } finally { mLocalDictionaryController.unlock(); diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java index e48e9e974..653fb760b 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -249,8 +249,7 @@ public class ExpandableDictionary extends Dictionary { @Override public ArrayList getWords(final WordComposer codes, - final CharSequence prevWordForBigrams, final WordCallback callback, - final ProximityInfo proximityInfo) { + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { synchronized (mUpdatingLock) { // If we need to update, start off a background task if (mRequiresReload) startDictionaryLoadingTaskLocked(); diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 1ae6557e1..29ecbe9ba 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -292,9 +292,8 @@ public class Suggest implements Dictionary.WordCallback { continue; final int dicTypeId = sDictKeyToDictIndex.get(key); final Dictionary dictionary = mUnigramDictionaries.get(key); - final ArrayList suggestions = - dictionary.getWords(wordComposerForLookup, prevWordForBigram, this, - proximityInfo); + final ArrayList suggestions = dictionary.getWords( + wordComposerForLookup, prevWordForBigram, proximityInfo); for (final SuggestedWordInfo suggestion : suggestions) { final String suggestionStr = suggestion.mWord.toString(); oldAddWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(), diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java index d706022bd..74f27e3cc 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java @@ -33,10 +33,9 @@ public class SynchronouslyLoadedContactsBinaryDictionary extends ContactsBinaryD @Override public synchronized ArrayList getWords(final WordComposer codes, - final CharSequence prevWordForBigrams, final WordCallback callback, - final ProximityInfo proximityInfo) { + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { syncReloadDictionaryIfRequired(); - return getWordsInner(codes, prevWordForBigrams, callback, proximityInfo); + return getWordsInner(codes, prevWordForBigrams, proximityInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java index 984e2e707..5b2a6edec 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java @@ -36,10 +36,9 @@ public class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDictionar @Override public synchronized ArrayList getWords(final WordComposer codes, - final CharSequence prevWordForBigrams, final WordCallback callback, - final ProximityInfo proximityInfo) { + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { syncReloadDictionaryIfRequired(); - return getWordsInner(codes, prevWordForBigrams, callback, proximityInfo); + return getWordsInner(codes, prevWordForBigrams, proximityInfo); } @Override