Follow API removal of LocaleList#getPrimary(). am: 706fce9bb0

am: 436b68dd73

* commit '436b68dd7383214d90153df5a71d630242a64478':
  Follow API removal of LocaleList#getPrimary().
main
Yohei Yukawa 2016-02-09 22:53:41 +00:00 committed by android-build-merger
commit 440b9983e5
2 changed files with 14 additions and 5 deletions

View File

@ -90,6 +90,9 @@ public final class EditorInfoCompatUtils {
if (localeList == null) { if (localeList == null) {
return null; return null;
} }
return LocaleListCompatUtils.getPrimary(localeList); if (LocaleListCompatUtils.isEmpty(localeList)) {
return null;
}
return LocaleListCompatUtils.get(localeList, 0);
} }
} }

View File

@ -21,14 +21,20 @@ import java.util.Locale;
public final class LocaleListCompatUtils { public final class LocaleListCompatUtils {
private static final Class CLASS_LocaleList = CompatUtils.getClass("android.util.LocaleList"); private static final Class CLASS_LocaleList = CompatUtils.getClass("android.util.LocaleList");
private static final Method METHOD_getPrimary = private static final Method METHOD_get =
CompatUtils.getMethod(CLASS_LocaleList, "getPrimary"); CompatUtils.getMethod(CLASS_LocaleList, "get", int.class);
private static final Method METHOD_isEmpty =
CompatUtils.getMethod(CLASS_LocaleList, "isEmpty");
private LocaleListCompatUtils() { private LocaleListCompatUtils() {
// This utility class is not publicly instantiable. // This utility class is not publicly instantiable.
} }
public static Locale getPrimary(final Object localeList) { public static boolean isEmpty(final Object localeList) {
return (Locale) CompatUtils.invoke(localeList, null, METHOD_getPrimary); 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);
} }
} }