Loading java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java +4 −1 Original line number Diff line number Diff line Loading @@ -90,6 +90,9 @@ public final class EditorInfoCompatUtils { if (localeList == null) { return null; } return LocaleListCompatUtils.getPrimary(localeList); if (LocaleListCompatUtils.isEmpty(localeList)) { return null; } return LocaleListCompatUtils.get(localeList, 0); } } java/src/com/android/inputmethod/compat/LocaleListCompatUtils.java +10 −4 Original line number Diff line number Diff line Loading @@ -21,14 +21,20 @@ import java.util.Locale; public final class LocaleListCompatUtils { private static final Class CLASS_LocaleList = CompatUtils.getClass("android.util.LocaleList"); private static final Method METHOD_getPrimary = CompatUtils.getMethod(CLASS_LocaleList, "getPrimary"); private static final Method METHOD_get = CompatUtils.getMethod(CLASS_LocaleList, "get", int.class); private static final Method METHOD_isEmpty = CompatUtils.getMethod(CLASS_LocaleList, "isEmpty"); private LocaleListCompatUtils() { // This utility class is not publicly instantiable. } public static Locale getPrimary(final Object localeList) { return (Locale) CompatUtils.invoke(localeList, null, METHOD_getPrimary); public static boolean isEmpty(final Object localeList) { return (Boolean) CompatUtils.invoke(localeList, Boolean.FALSE, METHOD_isEmpty); } public static Locale get(final Object localeList, final int index) { return (Locale) CompatUtils.invoke(localeList, null, METHOD_get, index); } } Loading
java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java +4 −1 Original line number Diff line number Diff line Loading @@ -90,6 +90,9 @@ public final class EditorInfoCompatUtils { if (localeList == null) { return null; } return LocaleListCompatUtils.getPrimary(localeList); if (LocaleListCompatUtils.isEmpty(localeList)) { return null; } return LocaleListCompatUtils.get(localeList, 0); } }
java/src/com/android/inputmethod/compat/LocaleListCompatUtils.java +10 −4 Original line number Diff line number Diff line Loading @@ -21,14 +21,20 @@ import java.util.Locale; public final class LocaleListCompatUtils { private static final Class CLASS_LocaleList = CompatUtils.getClass("android.util.LocaleList"); private static final Method METHOD_getPrimary = CompatUtils.getMethod(CLASS_LocaleList, "getPrimary"); private static final Method METHOD_get = CompatUtils.getMethod(CLASS_LocaleList, "get", int.class); private static final Method METHOD_isEmpty = CompatUtils.getMethod(CLASS_LocaleList, "isEmpty"); private LocaleListCompatUtils() { // This utility class is not publicly instantiable. } public static Locale getPrimary(final Object localeList) { return (Locale) CompatUtils.invoke(localeList, null, METHOD_getPrimary); public static boolean isEmpty(final Object localeList) { return (Boolean) CompatUtils.invoke(localeList, Boolean.FALSE, METHOD_isEmpty); } public static Locale get(final Object localeList, final int index) { return (Locale) CompatUtils.invoke(localeList, null, METHOD_get, index); } }