Merge "Remove the callback argument to getWords() (A15)"
commit
89239eeb74
|
@ -147,8 +147,7 @@ public class BinaryDictionary extends Dictionary {
|
|||
// proximityInfo and/or prevWordForBigrams may not be null.
|
||||
@Override
|
||||
public ArrayList<SuggestedWordInfo> 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);
|
||||
|
||||
|
|
|
@ -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<SuggestedWordInfo> 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
|
||||
|
|
|
@ -53,19 +53,18 @@ public class DictionaryCollection extends Dictionary {
|
|||
|
||||
@Override
|
||||
public ArrayList<SuggestedWordInfo> getWords(final WordComposer composer,
|
||||
final CharSequence prevWordForBigrams, final WordCallback callback,
|
||||
final ProximityInfo proximityInfo) {
|
||||
final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) {
|
||||
final CopyOnWriteArrayList<Dictionary> 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<SuggestedWordInfo> suggestions = dictionaries.get(0).getWords(composer,
|
||||
prevWordForBigrams, callback, proximityInfo);
|
||||
prevWordForBigrams, proximityInfo);
|
||||
if (null == suggestions) suggestions = new ArrayList<SuggestedWordInfo>();
|
||||
final int length = dictionaries.size();
|
||||
for (int i = 0; i < length; ++ i) {
|
||||
final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getWords(composer,
|
||||
prevWordForBigrams, callback, proximityInfo);
|
||||
prevWordForBigrams, proximityInfo);
|
||||
if (null != sugg) suggestions.addAll(sugg);
|
||||
}
|
||||
return suggestions;
|
||||
|
|
|
@ -196,22 +196,19 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
|
||||
@Override
|
||||
public ArrayList<SuggestedWordInfo> 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<SuggestedWordInfo> 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();
|
||||
|
|
|
@ -249,8 +249,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
|
||||
@Override
|
||||
public ArrayList<SuggestedWordInfo> 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();
|
||||
|
|
|
@ -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<SuggestedWordInfo> suggestions =
|
||||
dictionary.getWords(wordComposerForLookup, prevWordForBigram, this,
|
||||
proximityInfo);
|
||||
final ArrayList<SuggestedWordInfo> suggestions = dictionary.getWords(
|
||||
wordComposerForLookup, prevWordForBigram, proximityInfo);
|
||||
for (final SuggestedWordInfo suggestion : suggestions) {
|
||||
final String suggestionStr = suggestion.mWord.toString();
|
||||
oldAddWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(),
|
||||
|
|
|
@ -33,10 +33,9 @@ public class SynchronouslyLoadedContactsBinaryDictionary extends ContactsBinaryD
|
|||
|
||||
@Override
|
||||
public synchronized ArrayList<SuggestedWordInfo> 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
|
||||
|
|
|
@ -36,10 +36,9 @@ public class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDictionar
|
|||
|
||||
@Override
|
||||
public synchronized ArrayList<SuggestedWordInfo> 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
|
||||
|
|
Loading…
Reference in New Issue