diff options
author | 2011-08-08 23:44:24 -0700 | |
---|---|---|
committer | 2011-08-08 23:44:24 -0700 | |
commit | 741c683d5e73b9a1357457b7f45794ec5e0debf1 (patch) | |
tree | 23741f73a6dae914762fde33444eb48a29ee7b2f /java/src/com/android/inputmethod/latin/ContactsDictionary.java | |
parent | 33f3b60cf0660ad5893c1463077a47a03ac6bcf9 (diff) | |
parent | 14051e2b5343db4b0531b7b4b806da0c09d6e251 (diff) | |
download | latinime-741c683d5e73b9a1357457b7f45794ec5e0debf1.tar.gz latinime-741c683d5e73b9a1357457b7f45794ec5e0debf1.tar.xz latinime-741c683d5e73b9a1357457b7f45794ec5e0debf1.zip |
Merge "Stop reloading contacts when not appropriate."
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 |