Remove the callback argument to getBigrams() (A16)

Bug: 6252660
Bug: 6166228
Bug: 2704000
Bug: 6225530
Change-Id: I7457ac04f8cd4019fb86c986725aae3de1b1a65e
main
Jean Chalard 2012-06-21 13:40:51 +09:00
parent 89239eeb74
commit 2f1b6c9ea4
7 changed files with 14 additions and 17 deletions

View File

@ -108,7 +108,7 @@ public class BinaryDictionary extends Dictionary {
@Override
public ArrayList<SuggestedWordInfo> getBigrams(final WordComposer codes,
final CharSequence previousWord, final WordCallback callback) {
final CharSequence previousWord) {
if (mNativeDict == 0) return null;
int[] codePoints = StringUtils.toCodePointArray(previousWord.toString());

View File

@ -70,15 +70,13 @@ public abstract class Dictionary {
final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo);
/**
* Searches for pairs in the bigram dictionary that matches the previous word and all the
* possible words following are added through the callback object.
* Searches for pairs in the bigram dictionary that matches the previous word.
* @param composer the key sequence to match
* @param previousWord the word before
* @param callback the callback object to send possible word following previous word
* @return the list of suggestions
*/
public abstract ArrayList<SuggestedWordInfo> getBigrams(final WordComposer composer,
final CharSequence previousWord, final WordCallback callback);
final CharSequence previousWord);
/**
* Checks if the given word occurs in the dictionary

View File

@ -72,18 +72,18 @@ public class DictionaryCollection extends Dictionary {
@Override
public ArrayList<SuggestedWordInfo> getBigrams(final WordComposer composer,
final CharSequence previousWord, final WordCallback callback) {
final CharSequence previousWord) {
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).getBigrams(composer,
previousWord, callback);
previousWord);
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).getBigrams(composer, previousWord, callback);
dictionaries.get(i).getBigrams(composer, previousWord);
if (null != sugg) suggestions.addAll(sugg);
}
return suggestions;

View File

@ -219,17 +219,17 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
@Override
public ArrayList<SuggestedWordInfo> getBigrams(final WordComposer codes,
final CharSequence previousWord, final WordCallback callback) {
final CharSequence previousWord) {
asyncReloadDictionaryIfRequired();
return getBigramsInner(codes, previousWord, callback);
return getBigramsInner(codes, previousWord);
}
protected ArrayList<SuggestedWordInfo> getBigramsInner(final WordComposer codes,
final CharSequence previousWord, final WordCallback callback) {
final CharSequence previousWord) {
if (mLocalDictionaryController.tryLock()) {
try {
if (mBinaryDictionary != null) {
return mBinaryDictionary.getBigrams(codes, previousWord, callback);
return mBinaryDictionary.getBigrams(codes, previousWord);
}
} finally {
mLocalDictionaryController.unlock();

View File

@ -612,7 +612,7 @@ public class ExpandableDictionary extends Dictionary {
@Override
public ArrayList<SuggestedWordInfo> getBigrams(final WordComposer codes,
final CharSequence previousWord, final WordCallback callback) {
final CharSequence previousWord) {
if (!reloadDictionaryIfRequired()) {
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
runBigramReverseLookUp(previousWord, suggestions);

View File

@ -263,10 +263,9 @@ public class Suggest implements Dictionary.WordCallback {
final int dicTypeId = sDictKeyToDictIndex.get(key);
final Dictionary dictionary = mBigramDictionaries.get(key);
final ArrayList<SuggestedWordInfo> suggestions =
dictionary.getBigrams(wordComposer, prevWordForBigram, this);
dictionary.getBigrams(wordComposer, prevWordForBigram);
if (null != lowerPrevWord) {
suggestions.addAll(dictionary.getBigrams(wordComposer, lowerPrevWord,
this));
suggestions.addAll(dictionary.getBigrams(wordComposer, lowerPrevWord));
}
for (final SuggestedWordInfo suggestion : suggestions) {
final String suggestionStr = suggestion.mWord.toString();

View File

@ -789,7 +789,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
dictInfo = mDictionaryPool.takeOrGetNull();
if (null == dictInfo) return getNotInDictEmptySuggestions();
final ArrayList<SuggestedWordInfo> suggestions = dictInfo.mDictionary.getWords(
composer, prevWord, suggestionsGatherer, dictInfo.mProximityInfo);
composer, prevWord, dictInfo.mProximityInfo);
for (final SuggestedWordInfo suggestion : suggestions) {
final String suggestionStr = suggestion.mWord.toString();
suggestionsGatherer.oldAddWord(suggestionStr.toCharArray(), null, 0,