Close spell-checking dictionaries in a background thread
Bug: 6584677 Change-Id: Ifd9b0f995f4e0cf4d35a7ecde767826ab976f0b8
This commit is contained in:
parent
69b4e411e1
commit
769cecf7e7
1 changed files with 25 additions and 20 deletions
|
@ -372,6 +372,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
|
mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
|
||||||
final Map<String, Dictionary> oldWhitelistDictionaries = mWhitelistDictionaries;
|
final Map<String, Dictionary> oldWhitelistDictionaries = mWhitelistDictionaries;
|
||||||
mWhitelistDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
|
mWhitelistDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
|
||||||
|
new Thread("spellchecker_close_dicts") {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
for (DictionaryPool pool : oldPools.values()) {
|
for (DictionaryPool pool : oldPools.values()) {
|
||||||
pool.close();
|
pool.close();
|
||||||
}
|
}
|
||||||
|
@ -387,13 +390,15 @@ public class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
// or several pools, but it is shielded against multiple closing and it's
|
// or several pools, but it is shielded against multiple closing and it's
|
||||||
// safe to call it several times.
|
// safe to call it several times.
|
||||||
final Dictionary dictToClose = mContactsDictionary;
|
final Dictionary dictToClose = mContactsDictionary;
|
||||||
// TODO: revert to the concrete type when USE_BINARY_CONTACTS_DICTIONARY is no
|
// TODO: revert to the concrete type when USE_BINARY_CONTACTS_DICTIONARY
|
||||||
// longer needed
|
// is no longer needed
|
||||||
mContactsDictionary = null;
|
mContactsDictionary = null;
|
||||||
dictToClose.close();
|
dictToClose.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
private DictionaryPool getDictionaryPool(final String locale) {
|
private DictionaryPool getDictionaryPool(final String locale) {
|
||||||
DictionaryPool pool = mDictionaryPools.get(locale);
|
DictionaryPool pool = mDictionaryPools.get(locale);
|
||||||
|
|
Loading…
Reference in a new issue