Java 类android.text.style.LocaleSpan 实例源码

项目:365browser    文件:LollipopBrowserAccessibilityManager.java   
@Override
protected CharSequence computeText(String text, boolean annotateAsLink, String language) {
    CharSequence charSequence = super.computeText(text, annotateAsLink, language);
    if (!language.isEmpty() && !language.equals(mSystemLanguageTag)) {
        SpannableString spannable;
        if (charSequence instanceof SpannableString) {
            spannable = (SpannableString) charSequence;
        } else {
            spannable = new SpannableString(charSequence);
        }
        Locale locale = Locale.forLanguageTag(language);
        spannable.setSpan(new LocaleSpan(locale), 0, spannable.length(), 0);
        return spannable;
    }
    return charSequence;
}
项目:SpanEZ    文件:SpanEZTest.java   
@Test
public void locale_should_add_only_one_span() {
    spanBuilder.locale(range, Locale.US)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(LocaleSpan.class));
}
项目:spanner    文件:Spans.java   
/**
 * @see android.text.style.LocaleSpan#LocaleSpan(LocaleList)
 */
@RequiresApi(api = Build.VERSION_CODES.N)
public static Span locale(@NonNull final LocaleList localeList) {
    return new Span(new SpanBuilder() {
        @Override
        public Object build() {
            return new LocaleSpan(localeList);
        }
    });
}
项目:AndroidSpan    文件:AndroidSpan.java   
/**
 * @param text
 * @param locale Locale.CHINESE
 * @return
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public AndroidSpan drawLocaleSpan(String text, Locale locale) {
    LocaleSpan span = new LocaleSpan(locale);
    drawSpan(text, span);
    return this;
}
项目:AndroidSpan    文件:SpanOptions.java   
/**
 * @param locale Locale.CHINESE
 * @return
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public SpanOptions addLocaleSpan(Locale locale) {
    LocaleSpan span = new LocaleSpan(locale);
    listSpan.add(span);
    return this;
}