aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-02-28 09:37:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-02-28 09:37:23 +0000
commit58a536e41ac7b7def651176ca08eeb9b1353fa0f (patch)
tree7b14fda7fd1320a2896ccd3471baa3e572e63f70 /java/src/com/android/inputmethod/latin/UserBinaryDictionary.java
parent684f5f18b1dcc8f5338742629d579748395947ba (diff)
parentea89cb40b7641764d385bbc200c5910e08a29c1a (diff)
downloadlatinime-58a536e41ac7b7def651176ca08eeb9b1353fa0f.tar.gz
latinime-58a536e41ac7b7def651176ca08eeb9b1353fa0f.tar.xz
latinime-58a536e41ac7b7def651176ca08eeb9b1353fa0f.zip
Merge "Use dynamic operations to construct all ver4 dicts."
Diffstat (limited to 'java/src/com/android/inputmethod/latin/UserBinaryDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/UserBinaryDictionary.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java
index 3e3cbf063..8078ab541 100644
--- a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java
@@ -86,8 +86,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
public UserBinaryDictionary(final Context context, final Locale locale,
final boolean alsoUseMoreRestrictiveLocales, final File dictFile) {
- super(context, getDictName(NAME, locale, dictFile), locale, Dictionary.TYPE_USER,
- false /* isUpdatable */, dictFile);
+ super(context, getDictName(NAME, locale, dictFile), locale, Dictionary.TYPE_USER, dictFile);
if (null == locale) throw new NullPointerException(); // Catch the error earlier
final String localeStr = locale.toString();
if (SubtypeLocaleUtils.NO_LANGUAGE.equals(localeStr)) {
@@ -130,7 +129,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
}
@Override
- public void loadDictionaryAsync() {
+ public void loadInitialContentsLocked() {
// Split the locale. For example "en" => ["en"], "de_DE" => ["de", "DE"],
// "en_US_foo_bar_qux" => ["en", "US", "foo_bar_qux"] because of the limit of 3.
// This is correct for locale processing.
@@ -182,7 +181,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
try {
cursor = mContext.getContentResolver().query(
Words.CONTENT_URI, PROJECTION_QUERY, request.toString(), requestArguments, null);
- addWords(cursor);
+ addWordsLocked(cursor);
} catch (final SQLiteException e) {
Log.e(TAG, "SQLiteException in the remote User dictionary process.", e);
} finally {
@@ -236,7 +235,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
}
}
- private void addWords(final Cursor cursor) {
+ private void addWordsLocked(final Cursor cursor) {
final boolean hasShortcutColumn = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
if (cursor == null) return;
if (cursor.moveToFirst()) {
@@ -250,12 +249,16 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
final int adjustedFrequency = scaleFrequencyFromDefaultToLatinIme(frequency);
// Safeguard against adding really long words.
if (word.length() < MAX_WORD_LENGTH) {
- super.addWord(word, null, adjustedFrequency, 0 /* shortcutFreq */,
- false /* isNotAWord */);
- }
- if (null != shortcut && shortcut.length() < MAX_WORD_LENGTH) {
- super.addWord(shortcut, word, adjustedFrequency, USER_DICT_SHORTCUT_FREQUENCY,
- true /* isNotAWord */);
+ runGCIfRequiredLocked(true /* mindsBlockByGC */);
+ addWordDynamicallyLocked(word, adjustedFrequency, null /* shortcutTarget */,
+ 0 /* shortcutFreq */, false /* isNotAWord */,
+ false /* isBlacklisted */, BinaryDictionary.NOT_A_VALID_TIMESTAMP);
+ if (null != shortcut && shortcut.length() < MAX_WORD_LENGTH) {
+ runGCIfRequiredLocked(true /* mindsBlockByGC */);
+ addWordDynamicallyLocked(shortcut, adjustedFrequency, word,
+ USER_DICT_SHORTCUT_FREQUENCY, true /* isNotAWord */,
+ false /* isBlacklisted */, BinaryDictionary.NOT_A_VALID_TIMESTAMP);
+ }
}
cursor.moveToNext();
}
@@ -263,12 +266,12 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
}
@Override
- protected boolean hasContentChanged() {
+ protected boolean haveContentsChanged() {
return true;
}
@Override
- protected boolean needsToReloadBeforeWriting() {
+ protected boolean needsToReloadAfterCreation() {
return true;
}
}