Merge branch 'eclair-plus-aosp' of ssh://android-git.corp.google.com:29418/platform/packages/inputmethods/LatinIME into eclair-mr2-plus-aosp
commit
e9b0e47f80
|
@ -16,16 +16,11 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.provider.ContactsContract.Contacts;
|
import android.provider.ContactsContract.Contacts;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class ContactsDictionary extends ExpandableDictionary {
|
public class ContactsDictionary extends ExpandableDictionary {
|
||||||
|
|
||||||
|
@ -40,6 +35,8 @@ public class ContactsDictionary extends ExpandableDictionary {
|
||||||
|
|
||||||
private boolean mRequiresReload;
|
private boolean mRequiresReload;
|
||||||
|
|
||||||
|
private long mLastLoadedContacts;
|
||||||
|
|
||||||
public ContactsDictionary(Context context) {
|
public ContactsDictionary(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
// Perform a managed query. The Activity will handle closing and requerying the cursor
|
// Perform a managed query. The Activity will handle closing and requerying the cursor
|
||||||
|
@ -64,12 +61,17 @@ public class ContactsDictionary extends ExpandableDictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void loadDictionary() {
|
private synchronized void loadDictionary() {
|
||||||
|
long now = android.os.SystemClock.uptimeMillis();
|
||||||
|
if (mLastLoadedContacts == 0
|
||||||
|
|| now - mLastLoadedContacts > 30 * 60 * 1000 /* 30 minutes */) {
|
||||||
Cursor cursor = getContext().getContentResolver()
|
Cursor cursor = getContext().getContentResolver()
|
||||||
.query(Contacts.CONTENT_URI, PROJECTION, null, null, null);
|
.query(Contacts.CONTENT_URI, PROJECTION, null, null, null);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
addWords(cursor);
|
addWords(cursor);
|
||||||
}
|
}
|
||||||
mRequiresReload = false;
|
mRequiresReload = false;
|
||||||
|
mLastLoadedContacts = now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue