Methods Summary |
---|
public static java.util.Locale | constructLocaleFromString(java.lang.String localeStr)
if (TextUtils.isEmpty(localeStr))
return null;
String[] localeParams = localeStr.split("_", 3);
// The length of localeStr is guaranteed to always return a 1 <= value <= 3
// because localeStr is not empty.
if (localeParams.length == 1) {
return new Locale(localeParams[0]);
} else if (localeParams.length == 2) {
return new Locale(localeParams[0], localeParams[1]);
} else if (localeParams.length == 3) {
return new Locale(localeParams[0], localeParams[1], localeParams[2]);
}
return null;
|
public boolean | containsExtraValueKey(java.lang.String key)The string of ExtraValue in subtype should be defined as follows:
example: key0,key1=value1,key2,key3,key4=value4
return getExtraValueHashMap().containsKey(key);
|
public int | describeContents()
return 0;
|
public boolean | equals(java.lang.Object o)
if (o instanceof SpellCheckerSubtype) {
SpellCheckerSubtype subtype = (SpellCheckerSubtype) o;
return (subtype.hashCode() == hashCode())
&& (subtype.getNameResId() == getNameResId())
&& (subtype.getLocale().equals(getLocale()))
&& (subtype.getExtraValue().equals(getExtraValue()));
}
return false;
|
public java.lang.CharSequence | getDisplayName(android.content.Context context, java.lang.String packageName, android.content.pm.ApplicationInfo appInfo)
final Locale locale = constructLocaleFromString(mSubtypeLocale);
final String localeStr = locale != null ? locale.getDisplayName() : mSubtypeLocale;
if (mSubtypeNameResId == 0) {
return localeStr;
}
final CharSequence subtypeName = context.getPackageManager().getText(
packageName, mSubtypeNameResId, appInfo);
if (!TextUtils.isEmpty(subtypeName)) {
return String.format(subtypeName.toString(), localeStr);
} else {
return localeStr;
}
|
public java.lang.String | getExtraValue()
return mSubtypeExtraValue;
|
private java.util.HashMap | getExtraValueHashMap()
if (mExtraValueHashMapCache == null) {
mExtraValueHashMapCache = new HashMap<String, String>();
final String[] pairs = mSubtypeExtraValue.split(EXTRA_VALUE_PAIR_SEPARATOR);
final int N = pairs.length;
for (int i = 0; i < N; ++i) {
final String[] pair = pairs[i].split(EXTRA_VALUE_KEY_VALUE_SEPARATOR);
if (pair.length == 1) {
mExtraValueHashMapCache.put(pair[0], null);
} else if (pair.length > 1) {
if (pair.length > 2) {
Slog.w(TAG, "ExtraValue has two or more '='s");
}
mExtraValueHashMapCache.put(pair[0], pair[1]);
}
}
}
return mExtraValueHashMapCache;
|
public java.lang.String | getExtraValueOf(java.lang.String key)The string of ExtraValue in subtype should be defined as follows:
example: key0,key1=value1,key2,key3,key4=value4
return getExtraValueHashMap().get(key);
|
public java.lang.String | getLocale()
return mSubtypeLocale;
|
public int | getNameResId()
return mSubtypeNameResId;
|
public int | hashCode()
return mSubtypeHashCode;
|
private static int | hashCodeInternal(java.lang.String locale, java.lang.String extraValue)
return Arrays.hashCode(new Object[] {locale, extraValue});
|
public static java.util.List | sort(android.content.Context context, int flags, SpellCheckerInfo sci, java.util.List subtypeList)Sort the list of subtypes
if (sci == null) return subtypeList;
final HashSet<SpellCheckerSubtype> subtypesSet = new HashSet<SpellCheckerSubtype>(
subtypeList);
final ArrayList<SpellCheckerSubtype> sortedList = new ArrayList<SpellCheckerSubtype>();
int N = sci.getSubtypeCount();
for (int i = 0; i < N; ++i) {
SpellCheckerSubtype subtype = sci.getSubtypeAt(i);
if (subtypesSet.contains(subtype)) {
sortedList.add(subtype);
subtypesSet.remove(subtype);
}
}
// If subtypes in subtypesSet remain, that means these subtypes are not
// contained in sci, so the remaining subtypes will be appended.
for (SpellCheckerSubtype subtype: subtypesSet) {
sortedList.add(subtype);
}
return sortedList;
|
public void | writeToParcel(android.os.Parcel dest, int parcelableFlags)
dest.writeInt(mSubtypeNameResId);
dest.writeString(mSubtypeLocale);
dest.writeString(mSubtypeExtraValue);
|