am 65e3ae6f: Merge "Remove useless method call for spell checker."
* commit '65e3ae6f153a136902eaaf4da217496802c1daa1': Remove useless method call for spell checker.main
commit
1aacc4d60a
|
@ -25,34 +25,26 @@ import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public final class SynchronouslyLoadedContactsBinaryDictionary extends ContactsBinaryDictionary {
|
public final class SynchronouslyLoadedContactsBinaryDictionary extends ContactsBinaryDictionary {
|
||||||
private boolean mClosed;
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
public SynchronouslyLoadedContactsBinaryDictionary(final Context context, final Locale locale) {
|
public SynchronouslyLoadedContactsBinaryDictionary(final Context context, final Locale locale) {
|
||||||
super(context, locale);
|
super(context, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
||||||
final String prevWordForBigrams, final ProximityInfo proximityInfo,
|
final String prevWordForBigrams, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
|
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
|
||||||
reloadDictionaryIfRequired();
|
synchronized (mLock) {
|
||||||
return super.getSuggestions(codes, prevWordForBigrams, proximityInfo, blockOffensiveWords,
|
return super.getSuggestions(codes, prevWordForBigrams, proximityInfo,
|
||||||
additionalFeaturesOptions);
|
blockOffensiveWords, additionalFeaturesOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isValidWord(final String word) {
|
public boolean isValidWord(final String word) {
|
||||||
reloadDictionaryIfRequired();
|
synchronized (mLock) {
|
||||||
return isValidWordInner(word);
|
return super.isValidWord(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Protect against multiple closing
|
|
||||||
@Override
|
|
||||||
public synchronized void close() {
|
|
||||||
// Actually with the current implementation of ContactsDictionary it's safe to close
|
|
||||||
// several times, so the following protection is really only for foolproofing
|
|
||||||
if (mClosed) return;
|
|
||||||
mClosed = true;
|
|
||||||
super.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public final class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDictionary {
|
public final class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDictionary {
|
||||||
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
public SynchronouslyLoadedUserBinaryDictionary(final Context context, final Locale locale) {
|
public SynchronouslyLoadedUserBinaryDictionary(final Context context, final Locale locale) {
|
||||||
this(context, locale, false);
|
this(context, locale, false);
|
||||||
|
@ -36,17 +37,19 @@ public final class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDic
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
||||||
final String prevWordForBigrams, final ProximityInfo proximityInfo,
|
final String prevWordForBigrams, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
|
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
|
||||||
reloadDictionaryIfRequired();
|
synchronized (mLock) {
|
||||||
return super.getSuggestions(codes, prevWordForBigrams, proximityInfo, blockOffensiveWords,
|
return super.getSuggestions(codes, prevWordForBigrams, proximityInfo,
|
||||||
additionalFeaturesOptions);
|
blockOffensiveWords, additionalFeaturesOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isValidWord(final String word) {
|
public boolean isValidWord(final String word) {
|
||||||
reloadDictionaryIfRequired();
|
synchronized (mLock) {
|
||||||
return isValidWordInner(word);
|
return super.isValidWord(word);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,6 +383,8 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
new Thread("spellchecker_close_dicts") {
|
new Thread("spellchecker_close_dicts") {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
// Contacts dictionary can be closed multiple times here. If the dictionary is
|
||||||
|
// already closed, extra closings are no-ops, so it's safe.
|
||||||
for (DictionaryPool pool : oldPools.values()) {
|
for (DictionaryPool pool : oldPools.values()) {
|
||||||
pool.close();
|
pool.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue