am a9861ac8
: Merge "Handle personalization dictionary as an ExpandableBinaryDictionary."
* commit 'a9861ac81419774eeed1460c7beea5d4d407bb5f': Handle personalization dictionary as an ExpandableBinaryDictionary.
This commit is contained in:
commit
aee379d212
3 changed files with 12 additions and 26 deletions
|
@ -73,18 +73,16 @@ public class DictionaryFacilitatorForSuggest {
|
||||||
CollectionUtils.newConcurrentHashMap();
|
CollectionUtils.newConcurrentHashMap();
|
||||||
// TODO: Remove sub dictionary members and use mSubDictMap.
|
// TODO: Remove sub dictionary members and use mSubDictMap.
|
||||||
public final UserBinaryDictionary mUserDictionary;
|
public final UserBinaryDictionary mUserDictionary;
|
||||||
public final PersonalizationDictionary mPersonalizationDictionary;
|
|
||||||
|
|
||||||
public Dictionaries() {
|
public Dictionaries() {
|
||||||
mLocale = null;
|
mLocale = null;
|
||||||
mUserDictionary = null;
|
mUserDictionary = null;
|
||||||
mPersonalizationDictionary = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionaries(final Locale locale, final Dictionary mainDict,
|
public Dictionaries(final Locale locale, final Dictionary mainDict,
|
||||||
final ExpandableBinaryDictionary contactsDict, final UserBinaryDictionary userDict,
|
final ExpandableBinaryDictionary contactsDict, final UserBinaryDictionary userDict,
|
||||||
final ExpandableBinaryDictionary userHistoryDict,
|
final ExpandableBinaryDictionary userHistoryDict,
|
||||||
final PersonalizationDictionary personalizationDict) {
|
final ExpandableBinaryDictionary personalizationDict) {
|
||||||
mLocale = locale;
|
mLocale = locale;
|
||||||
// Main dictionary can be asynchronously loaded.
|
// Main dictionary can be asynchronously loaded.
|
||||||
setMainDict(mainDict);
|
setMainDict(mainDict);
|
||||||
|
@ -92,8 +90,7 @@ public class DictionaryFacilitatorForSuggest {
|
||||||
mUserDictionary = userDict;
|
mUserDictionary = userDict;
|
||||||
setSubDict(Dictionary.TYPE_USER, mUserDictionary);
|
setSubDict(Dictionary.TYPE_USER, mUserDictionary);
|
||||||
setSubDict(Dictionary.TYPE_USER_HISTORY, userHistoryDict);
|
setSubDict(Dictionary.TYPE_USER_HISTORY, userHistoryDict);
|
||||||
mPersonalizationDictionary = personalizationDict;
|
setSubDict(Dictionary.TYPE_PERSONALIZATION, personalizationDict);
|
||||||
setSubDict(Dictionary.TYPE_PERSONALIZATION, mPersonalizationDictionary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSubDict(final String dictType, final ExpandableBinaryDictionary dict) {
|
private void setSubDict(final String dictType, final ExpandableBinaryDictionary dict) {
|
||||||
|
@ -197,10 +194,10 @@ public class DictionaryFacilitatorForSuggest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open or move personalization dictionary.
|
// Open or move personalization dictionary.
|
||||||
final PersonalizationDictionary newPersonalizationDict;
|
final ExpandableBinaryDictionary newPersonalizationDict;
|
||||||
if (!closePersonalizationDictionary
|
if (!closePersonalizationDictionary
|
||||||
&& mDictionaries.hasDict(Dictionary.TYPE_PERSONALIZATION)) {
|
&& mDictionaries.hasDict(Dictionary.TYPE_PERSONALIZATION)) {
|
||||||
newPersonalizationDict = mDictionaries.mPersonalizationDictionary;
|
newPersonalizationDict = mDictionaries.getSubDict(Dictionary.TYPE_PERSONALIZATION);
|
||||||
} else if (usePersonalizedDicts) {
|
} else if (usePersonalizedDicts) {
|
||||||
newPersonalizationDict =
|
newPersonalizationDict =
|
||||||
PersonalizationHelper.getPersonalizationDictionary(context, newLocale);
|
PersonalizationHelper.getPersonalizationDictionary(context, newLocale);
|
||||||
|
@ -344,8 +341,8 @@ public class DictionaryFacilitatorForSuggest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flushPersonalizationDictionary() {
|
public void flushPersonalizationDictionary() {
|
||||||
final PersonalizationDictionary personalizationDict =
|
final ExpandableBinaryDictionary personalizationDict =
|
||||||
mDictionaries.mPersonalizationDictionary;
|
mDictionaries.getSubDict(Dictionary.TYPE_PERSONALIZATION);
|
||||||
if (personalizationDict != null) {
|
if (personalizationDict != null) {
|
||||||
personalizationDict.asyncFlushBinaryDictionary();
|
personalizationDict.asyncFlushBinaryDictionary();
|
||||||
}
|
}
|
||||||
|
@ -537,15 +534,16 @@ public class DictionaryFacilitatorForSuggest {
|
||||||
public void addMultipleDictionaryEntriesToPersonalizationDictionary(
|
public void addMultipleDictionaryEntriesToPersonalizationDictionary(
|
||||||
final ArrayList<LanguageModelParam> languageModelParams,
|
final ArrayList<LanguageModelParam> languageModelParams,
|
||||||
final ExpandableBinaryDictionary.AddMultipleDictionaryEntriesCallback callback) {
|
final ExpandableBinaryDictionary.AddMultipleDictionaryEntriesCallback callback) {
|
||||||
final PersonalizationDictionary personalizationDict =
|
final ExpandableBinaryDictionary personalizationDict =
|
||||||
mDictionaries.mPersonalizationDictionary;
|
mDictionaries.getSubDict(Dictionary.TYPE_PERSONALIZATION);
|
||||||
if (personalizationDict == null) {
|
if (personalizationDict == null || languageModelParams == null
|
||||||
|
|| languageModelParams.isEmpty()) {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onFinished();
|
callback.onFinished();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
personalizationDict.addMultipleDictionaryEntriesToDictionary(languageModelParams, callback);
|
personalizationDict.addMultipleDictionaryEntriesDynamically(languageModelParams, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dumpDictionaryForDebug(final String dictName) {
|
public void dumpDictionaryForDebug(final String dictName) {
|
||||||
|
|
|
@ -368,7 +368,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
||||||
/**
|
/**
|
||||||
* Dynamically add multiple entries to the dictionary.
|
* Dynamically add multiple entries to the dictionary.
|
||||||
*/
|
*/
|
||||||
protected void addMultipleDictionaryEntriesDynamically(
|
public void addMultipleDictionaryEntriesDynamically(
|
||||||
final ArrayList<LanguageModelParam> languageModelParams,
|
final ArrayList<LanguageModelParam> languageModelParams,
|
||||||
final AddMultipleDictionaryEntriesCallback callback) {
|
final AddMultipleDictionaryEntriesCallback callback) {
|
||||||
reloadDictionaryIfRequired();
|
reloadDictionaryIfRequired();
|
||||||
|
|
|
@ -87,18 +87,6 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMultipleDictionaryEntriesToDictionary(
|
|
||||||
final ArrayList<LanguageModelParam> languageModelParams,
|
|
||||||
final ExpandableBinaryDictionary.AddMultipleDictionaryEntriesCallback callback) {
|
|
||||||
if (languageModelParams == null || languageModelParams.isEmpty()) {
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onFinished();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
addMultipleDictionaryEntriesDynamically(languageModelParams, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadInitialContentsLocked() {
|
protected void loadInitialContentsLocked() {
|
||||||
// No initial contents.
|
// No initial contents.
|
||||||
|
|
Loading…
Reference in a new issue