aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-06-06 21:52:46 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-06 21:52:46 -0700
commitc8a120f97029f912f55e2dace5ad7363e028e3bb (patch)
tree617c0e4ebe90541d8e03a4246166a1b04c740b90 /java/src/com/android/inputmethod
parent9b300f0caa978f4fc103c34b9be0165a49a2e24b (diff)
parenteead5492615f0b05ef85ca1f88d3a41ce3f8d496 (diff)
downloadlatinime-c8a120f97029f912f55e2dace5ad7363e028e3bb.tar.gz
latinime-c8a120f97029f912f55e2dace5ad7363e028e3bb.tar.xz
latinime-c8a120f97029f912f55e2dace5ad7363e028e3bb.zip
am eead5492: am 769cecf7: Close spell-checking dictionaries in a background thread
* commit 'eead5492615f0b05ef85ca1f88d3a41ce3f8d496': Close spell-checking dictionaries in a background thread
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java45
1 files changed, 25 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 802322ccd..d34cad205 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -372,27 +372,32 @@ public class AndroidSpellCheckerService extends SpellCheckerService
mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
final Map<String, Dictionary> oldWhitelistDictionaries = mWhitelistDictionaries;
mWhitelistDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
- for (DictionaryPool pool : oldPools.values()) {
- pool.close();
- }
- for (Dictionary dict : oldUserDictionaries.values()) {
- dict.close();
- }
- for (Dictionary dict : oldWhitelistDictionaries.values()) {
- dict.close();
- }
- synchronized (mUseContactsLock) {
- if (null != mContactsDictionary) {
- // The synchronously loaded contacts dictionary should have been in one
- // or several pools, but it is shielded against multiple closing and it's
- // safe to call it several times.
- final Dictionary dictToClose = mContactsDictionary;
- // TODO: revert to the concrete type when USE_BINARY_CONTACTS_DICTIONARY is no
- // longer needed
- mContactsDictionary = null;
- dictToClose.close();
+ new Thread("spellchecker_close_dicts") {
+ @Override
+ public void run() {
+ for (DictionaryPool pool : oldPools.values()) {
+ pool.close();
+ }
+ for (Dictionary dict : oldUserDictionaries.values()) {
+ dict.close();
+ }
+ for (Dictionary dict : oldWhitelistDictionaries.values()) {
+ dict.close();
+ }
+ synchronized (mUseContactsLock) {
+ if (null != mContactsDictionary) {
+ // The synchronously loaded contacts dictionary should have been in one
+ // or several pools, but it is shielded against multiple closing and it's
+ // safe to call it several times.
+ final Dictionary dictToClose = mContactsDictionary;
+ // TODO: revert to the concrete type when USE_BINARY_CONTACTS_DICTIONARY
+ // is no longer needed
+ mContactsDictionary = null;
+ dictToClose.close();
+ }
+ }
}
- }
+ }.start();
}
private DictionaryPool getDictionaryPool(final String locale) {