Add a method to create dict with additional attributes.

Bug: 13197276
Change-Id: I80311a51d9e98bfeb8c0dd9cd4adde93af366d54
This commit is contained in:
Keisuke Kuroyanagi 2014-02-26 19:03:27 +09:00
parent 6112cc26a7
commit 18f91cf617

View file

@ -50,6 +50,7 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
public final Locale mLocale; public final Locale mLocale;
private final String mDictName; private final String mDictName;
private Map<String, String> mAdditionalAttributeMap = null;
protected DecayingExpandableBinaryDictionaryBase(final Context context, protected DecayingExpandableBinaryDictionaryBase(final Context context,
final String dictName, final Locale locale, final String dictionaryType, final String dictName, final Locale locale, final String dictionaryType,
@ -78,7 +79,10 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
@Override @Override
protected Map<String, String> getHeaderAttributeMap() { protected Map<String, String> getHeaderAttributeMap() {
HashMap<String, String> attributeMap = new HashMap<String, String>(); final Map<String, String> attributeMap = new HashMap<String, String>();
if (mAdditionalAttributeMap != null) {
attributeMap.putAll(mAdditionalAttributeMap);
}
attributeMap.put(DictionaryHeader.USES_FORGETTING_CURVE_KEY, attributeMap.put(DictionaryHeader.USES_FORGETTING_CURVE_KEY,
DictionaryHeader.ATTRIBUTE_VALUE_TRUE); DictionaryHeader.ATTRIBUTE_VALUE_TRUE);
attributeMap.put(DictionaryHeader.HAS_HISTORICAL_INFO_KEY, attributeMap.put(DictionaryHeader.HAS_HISTORICAL_INFO_KEY,
@ -152,6 +156,13 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
asyncFlushBinaryDictionary(); asyncFlushBinaryDictionary();
} }
@UsedForTesting
public void clearAndFlushDictionaryWithAdditionalAttributes(
final Map<String, String> attributeMap) {
mAdditionalAttributeMap = attributeMap;
clearAndFlushDictionary();
}
/* package */ void decayIfNeeded() { /* package */ void decayIfNeeded() {
runGCIfRequired(false /* mindsBlockByGC */); runGCIfRequired(false /* mindsBlockByGC */);
} }