diff options
author | 2014-05-09 03:48:19 +0000 | |
---|---|---|
committer | 2014-05-09 03:48:19 +0000 | |
commit | 28ebe2db237b5e0b5989ebcca644f469ecda66e3 (patch) | |
tree | e8b0e730da7a0d46cd21fe62ea23cd499a310a17 /java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java | |
parent | 943e28d202787c15c49c00f98267ca6cc1be7a3f (diff) | |
parent | 9898ee626733a0b07177df67df213b4fd42f30c1 (diff) | |
download | latinime-28ebe2db237b5e0b5989ebcca644f469ecda66e3.tar.gz latinime-28ebe2db237b5e0b5989ebcca644f469ecda66e3.tar.xz latinime-28ebe2db237b5e0b5989ebcca644f469ecda66e3.zip |
Merge "Check whether contacts have changed using hashCode()."
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index e3bed318e..b41981712 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -92,8 +92,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { /** Indicates whether a task for reloading the dictionary has been scheduled. */ private final AtomicBoolean mIsReloading; - /** Indicates whether the current dictionary needs to be reloaded. */ - private boolean mNeedsToReload; + /** Indicates whether the current dictionary needs to be recreated. */ + private boolean mNeedsToRecreate; private final ReentrantReadWriteLock mLock; @@ -107,13 +107,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { */ protected abstract void loadInitialContentsLocked(); - /** - * Indicates that the source dictionary contents have changed and a rebuild of the binary file - * is required. If it returns false, the next reload will only read the current binary - * dictionary from file. - */ - protected abstract boolean haveContentsChanged(); - private boolean matchesExpectedBinaryDictFormatVersionForThisType(final int formatVersion) { return formatVersion == FormatSpec.VERSION4; } @@ -147,7 +140,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { mDictFile = getDictFile(context, dictName, dictFile); mBinaryDictionary = null; mIsReloading = new AtomicBoolean(); - mNeedsToReload = false; + mNeedsToRecreate = false; mLock = new ReentrantReadWriteLock(); } @@ -489,11 +482,11 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } /** - * Marks that the dictionary needs to be reloaded. + * Marks that the dictionary needs to be recreated. * */ - protected void setNeedsToReload() { - mNeedsToReload = true; + protected void setNeedsToRecreate() { + mNeedsToRecreate = true; } /** @@ -511,7 +504,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { * Returns whether a dictionary reload is required. */ private boolean isReloadRequired() { - return mBinaryDictionary == null || mNeedsToReload; + return mBinaryDictionary == null || mNeedsToRecreate; } /** @@ -523,8 +516,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { @Override public void run() { try { - // TODO: Quit checking contents in ExpandableBinaryDictionary. - if (!mDictFile.exists() || (mNeedsToReload && haveContentsChanged())) { + if (!mDictFile.exists() || mNeedsToRecreate) { // If the dictionary file does not exist or contents have been updated, // generate a new one. createNewDictionaryLocked(); @@ -536,12 +528,12 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { && matchesExpectedBinaryDictFormatVersionForThisType( mBinaryDictionary.getFormatVersion()))) { // Binary dictionary or its format version is not valid. Regenerate - // the dictionary file. writeBinaryDictionary will remove the + // the dictionary file. createNewDictionaryLocked will remove the // existing files if appropriate. createNewDictionaryLocked(); } } - mNeedsToReload = false; + mNeedsToRecreate = false; } finally { mIsReloading.set(false); } |