diff options
author | 2011-08-09 11:54:10 +0900 | |
---|---|---|
committer | 2011-08-09 12:49:19 +0900 | |
commit | 14051e2b5343db4b0531b7b4b806da0c09d6e251 (patch) | |
tree | de4d3d50fc7c7eaaa72144f322442ff6df890d0e /java/src/com/android/inputmethod/latin/ContactsDictionary.java | |
parent | 0484758b0e1fd4e82d176be47f8fc0d608e1bd09 (diff) | |
download | latinime-14051e2b5343db4b0531b7b4b806da0c09d6e251.tar.gz latinime-14051e2b5343db4b0531b7b4b806da0c09d6e251.tar.xz latinime-14051e2b5343db4b0531b7b4b806da0c09d6e251.zip |
Stop reloading contacts when not appropriate.
A recent change had the contacts reloaded every time a new field
is touched. This change not only fixes the problem, but also removes
reloading contacts when changing language, which should make language
switch within LatinIME lighter.
Bug: 5125034
Change-Id: Ia61c4f75a8617113cdce88a2e2c6fdf073146a2d
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ContactsDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/ContactsDictionary.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/ContactsDictionary.java b/java/src/com/android/inputmethod/latin/ContactsDictionary.java index 66a041508..8a7dfb839 100644 --- a/java/src/com/android/inputmethod/latin/ContactsDictionary.java +++ b/java/src/com/android/inputmethod/latin/ContactsDictionary.java @@ -49,20 +49,28 @@ public class ContactsDictionary extends ExpandableDictionary { private long mLastLoadedContacts; - public ContactsDictionary(Context context, int dicTypeId) { + public ContactsDictionary(final Context context, final int dicTypeId) { super(context, dicTypeId); + registerObserver(context); + loadDictionary(); + } + + private synchronized void registerObserver(final Context context) { // Perform a managed query. The Activity will handle closing and requerying the cursor // when needed. + if (mObserver != null) return; ContentResolver cres = context.getContentResolver(); - cres.registerContentObserver( - Contacts.CONTENT_URI, true,mObserver = new ContentObserver(null) { + Contacts.CONTENT_URI, true, mObserver = new ContentObserver(null) { @Override public void onChange(boolean self) { setRequiresReload(true); } }); - loadDictionary(); + } + + public void reopen(final Context context) { + registerObserver(context); } @Override |