Use shared constants in old+new facilitators.

Change-Id: I18b701df6ecbcc20ff0c664c218289179c4b2b2d
main
Dan Zivkovic 2015-02-04 18:55:39 -08:00
parent 6e0467c20e
commit 23d19626f3
3 changed files with 32 additions and 31 deletions

View File

@ -43,6 +43,35 @@ import javax.annotation.Nullable;
* DictionaryFacilitator as a client for interacting with dictionaries.
*/
public interface DictionaryFacilitator {
public static final String[] ALL_DICTIONARY_TYPES = new String[] {
Dictionary.TYPE_MAIN,
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_USER,
Dictionary.TYPE_CONTACTS};
public static final String[] DYNAMIC_DICTIONARY_TYPES = new String[] {
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_USER,
Dictionary.TYPE_CONTACTS};
/**
* {@link Dictionary#TYPE_USER} is deprecated, except for the spelling service.
*/
public static final String[] DICTIONARY_TYPES_FOR_SPELLING = new String[] {
Dictionary.TYPE_MAIN,
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_USER,
Dictionary.TYPE_CONTACTS};
/**
* {@link Dictionary#TYPE_USER} is deprecated, except for the spelling service.
*/
public static final String[] DICTIONARY_TYPES_FOR_SUGGESTIONS = new String[] {
Dictionary.TYPE_MAIN,
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_CONTACTS};
/**
* Returns whether this facilitator is exactly for this list of locales.
*

View File

@ -78,34 +78,6 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
private final Object mLock = new Object();
private final DistracterFilter mDistracterFilter;
private static final String[] ALL_DICTIONARY_TYPES = new String[] {
Dictionary.TYPE_MAIN,
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_USER,
Dictionary.TYPE_CONTACTS};
private static final String[] SUB_DICTIONARY_TYPES = new String[] {
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_USER,
Dictionary.TYPE_CONTACTS};
/**
* {@link Dictionary#TYPE_USER} is deprecated, except for the spelling service.
*/
private static final String[] DICTIONARY_TYPES_FOR_SPELLING = new String[] {
Dictionary.TYPE_MAIN,
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_USER,
Dictionary.TYPE_CONTACTS};
/**
* {@link Dictionary#TYPE_USER} is deprecated, except for the spelling service.
*/
private static final String[] DICTIONARY_TYPES_FOR_SUGGESTIONS = new String[] {
Dictionary.TYPE_MAIN,
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_CONTACTS};
public static final Map<String, Class<? extends ExpandableBinaryDictionary>>
DICT_TYPE_TO_CLASS = new HashMap<>();
@ -419,7 +391,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
if (null == currentDictionaryGroupForLocale) {
continue;
}
for (final String dictType : SUB_DICTIONARY_TYPES) {
for (final String dictType : DYNAMIC_DICTIONARY_TYPES) {
if (currentDictionaryGroupForLocale.hasDict(dictType, account)) {
dictTypeForLocale.add(dictType);
}
@ -840,7 +812,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
final ArrayList<Pair<String, DictionaryStats>> statsOfEnabledSubDicts = new ArrayList<>();
final DictionaryGroup[] dictionaryGroups = mDictionaryGroups;
for (final DictionaryGroup dictionaryGroup : dictionaryGroups) {
for (final String dictType : SUB_DICTIONARY_TYPES) {
for (final String dictType : DYNAMIC_DICTIONARY_TYPES) {
final ExpandableBinaryDictionary dictionary = dictionaryGroup.getSubDict(dictType);
if (dictionary == null) continue;
statsOfEnabledSubDicts.add(new Pair<>(dictType, dictionary.getDictionaryStats()));

View File

@ -128,7 +128,7 @@ public class DictionaryFacilitatorLruCache {
public DictionaryFacilitator get(final Locale locale) {
DictionaryFacilitator dictionaryFacilitator = mLruCache.get(locale);
if (dictionaryFacilitator != null) {
// dictionary falicitator for the locale is in the cache.
// dictionary facilitator for the locale is in the cache.
return dictionaryFacilitator;
}
synchronized (mLock) {