mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 06:09:09 +00:00
Add persistence for user history dictionary
User history dictionary was not flushing to disk on close, added that logic so (unless there's a crash) the user history should be persisted.
This commit is contained in:
parent
dd7b56fbb3
commit
206fc18ec3
3 changed files with 13 additions and 0 deletions
|
@ -225,6 +225,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
|
||||
@Override
|
||||
public void onFinishInput(Context context) {
|
||||
flushDictionaries();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -459,6 +460,18 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
}
|
||||
}
|
||||
|
||||
public void flushDictionaries() {
|
||||
final DictionaryGroup dictionaryGroupToClose;
|
||||
synchronized (mLock) {
|
||||
dictionaryGroupToClose = mDictionaryGroup;
|
||||
mDictionaryGroup = new DictionaryGroup();
|
||||
}
|
||||
for (final String dictType : ALL_DICTIONARY_TYPES) {
|
||||
ExpandableBinaryDictionary dict = dictionaryGroupToClose.getSubDict(dictType);
|
||||
if (dict != null) dict.asyncFlushBinaryDictionary();
|
||||
}
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
public ExpandableBinaryDictionary getSubDictForTesting(final String dictName) {
|
||||
return mDictionaryGroup.getSubDict(dictName);
|
||||
|
|
Binary file not shown.
BIN
dictionaries/en_wordlist.combined.gz
Executable file → Normal file
BIN
dictionaries/en_wordlist.combined.gz
Executable file → Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue