@Test public void testMaximizeAndGetScript() { assertEquals("Latn", ICUCompat.maximizeAndGetScript(new Locale("en", "US"))); if (Build.VERSION.SDK_INT >= 21) { assertEquals( "Visp", ICUCompat.maximizeAndGetScript(Locale.forLanguageTag("en-Visp-US"))); } }
@Nullable public static String maximizeAndGetScript(Locale locale) { if (Build.VERSION.SDK_INT >= 21) { try { final Object[] args = new Object[] { locale }; return ((Locale) sAddLikelySubtagsMethod.invoke(null, args)).getScript(); } catch (InvocationTargetException e) { Log.w(TAG, e); } catch (IllegalAccessException e) { Log.w(TAG, e); } return locale.getScript(); } else { final String localeWithSubtags = addLikelySubtags(locale); if (localeWithSubtags != null) { return getScript(localeWithSubtags); } return null; } }
ICUCompat { @Nullable public static String maximizeAndGetScript(Locale locale) { if (Build.VERSION.SDK_INT >= 21) { try { final Object[] args = new Object[] { locale }; return ((Locale) sAddLikelySubtagsMethod.invoke(null, args)).getScript(); } catch (InvocationTargetException e) { Log.w(TAG, e); } catch (IllegalAccessException e) { Log.w(TAG, e); } return locale.getScript(); } else { final String localeWithSubtags = addLikelySubtags(locale); if (localeWithSubtags != null) { return getScript(localeWithSubtags); } return null; } } }
ICUCompat { @Nullable public static String maximizeAndGetScript(Locale locale) { if (Build.VERSION.SDK_INT >= 21) { try { final Object[] args = new Object[] { locale }; return ((Locale) sAddLikelySubtagsMethod.invoke(null, args)).getScript(); } catch (InvocationTargetException e) { Log.w(TAG, e); } catch (IllegalAccessException e) { Log.w(TAG, e); } return locale.getScript(); } else { final String localeWithSubtags = addLikelySubtags(locale); if (localeWithSubtags != null) { return getScript(localeWithSubtags); } return null; } } private  ICUCompat(); }
ICUCompat { @Nullable public static String maximizeAndGetScript(Locale locale) { if (Build.VERSION.SDK_INT >= 21) { try { final Object[] args = new Object[] { locale }; return ((Locale) sAddLikelySubtagsMethod.invoke(null, args)).getScript(); } catch (InvocationTargetException e) { Log.w(TAG, e); } catch (IllegalAccessException e) { Log.w(TAG, e); } return locale.getScript(); } else { final String localeWithSubtags = addLikelySubtags(locale); if (localeWithSubtags != null) { return getScript(localeWithSubtags); } return null; } } private  ICUCompat(); @Nullable static String maximizeAndGetScript(Locale locale); }
ICUCompat { @Nullable public static String maximizeAndGetScript(Locale locale) { if (Build.VERSION.SDK_INT >= 21) { try { final Object[] args = new Object[] { locale }; return ((Locale) sAddLikelySubtagsMethod.invoke(null, args)).getScript(); } catch (InvocationTargetException e) { Log.w(TAG, e); } catch (IllegalAccessException e) { Log.w(TAG, e); } return locale.getScript(); } else { final String localeWithSubtags = addLikelySubtags(locale); if (localeWithSubtags != null) { return getScript(localeWithSubtags); } return null; } } private  ICUCompat(); @Nullable static String maximizeAndGetScript(Locale locale);  }