diff options
author | 2014-05-09 03:51:47 +0000 | |
---|---|---|
committer | 2014-05-09 03:51:47 +0000 | |
commit | a73bcfac390c2af107f059d303d38fa4663fa778 (patch) | |
tree | e8b0e730da7a0d46cd21fe62ea23cd499a310a17 /java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java | |
parent | 377f4903fa5a344ff9d63508b511ef6f1e8ef4aa (diff) | |
parent | 28ebe2db237b5e0b5989ebcca644f469ecda66e3 (diff) | |
download | latinime-a73bcfac390c2af107f059d303d38fa4663fa778.tar.gz latinime-a73bcfac390c2af107f059d303d38fa4663fa778.tar.xz latinime-a73bcfac390c2af107f059d303d38fa4663fa778.zip |
am 28ebe2db: Merge "Check whether contacts have changed using hashCode()."
* commit '28ebe2db237b5e0b5989ebcca644f469ecda66e3':
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); } |