in litho-widget/src/main/java/com/facebook/litho/widget/TextStylesHelper.java [55:182]
public static void onLoadStyle(
ComponentContext c,
Output<TruncateAt> ellipsize,
Output<Float> extraSpacing,
Output<Boolean> shouldIncludeFontPadding,
Output<Float> spacingMultiplier,
Output<Integer> minLines,
Output<Integer> maxLines,
Output<Integer> minEms,
Output<Integer> maxEms,
Output<Integer> minTextWidth,
Output<Integer> maxTextWidth,
Output<Boolean> isSingleLine,
Output<CharSequence> text,
Output<ColorStateList> textColorStateList,
Output<Integer> linkColor,
Output<Integer> highlightColor,
Output<Integer> textSize,
Output<TextAlignment> textAlignment,
Output<Integer> breakStrategy,
Output<Integer> hyphenationFrequency,
Output<Integer> justificationMode,
Output<Integer> textStyle,
Output<Float> shadowRadius,
Output<Float> shadowDx,
Output<Float> shadowDy,
Output<Integer> shadowColor,
Output<VerticalGravity> verticalGravity,
Output<Typeface> typeface) {
final Resources.Theme theme = c.getAndroidContext().getTheme();
// check first if provided attributes contain textAppearance. As an analogy to TextView
// behavior,
// we will parse textAppearance attributes first and then will override leftovers from main
// style
TypedArray a;
if (ComponentsConfiguration.NEEDS_THEME_SYNCHRONIZATION) {
synchronized (theme) {
a = c.obtainStyledAttributes(R.styleable.Text_TextAppearanceAttr, 0);
}
} else {
a = c.obtainStyledAttributes(R.styleable.Text_TextAppearanceAttr, 0);
}
int textAppearanceResId =
a.getResourceId(R.styleable.Text_TextAppearanceAttr_android_textAppearance, -1);
a.recycle();
if (textAppearanceResId != -1) {
if (ComponentsConfiguration.NEEDS_THEME_SYNCHRONIZATION) {
synchronized (theme) {
a = theme.obtainStyledAttributes(textAppearanceResId, R.styleable.Text);
}
} else {
a = theme.obtainStyledAttributes(textAppearanceResId, R.styleable.Text);
}
resolveStyleAttrsForTypedArray(
a,
ellipsize,
extraSpacing,
shouldIncludeFontPadding,
spacingMultiplier,
minLines,
maxLines,
minEms,
maxEms,
minTextWidth,
maxTextWidth,
isSingleLine,
text,
textColorStateList,
linkColor,
highlightColor,
textSize,
textAlignment,
breakStrategy,
hyphenationFrequency,
justificationMode,
textStyle,
shadowRadius,
shadowDx,
shadowDy,
shadowColor,
verticalGravity,
typeface);
a.recycle();
}
// now (after we parsed textAppearance) we can move on to main style attributes
if (ComponentsConfiguration.NEEDS_THEME_SYNCHRONIZATION) {
synchronized (theme) {
a = c.obtainStyledAttributes(R.styleable.Text, 0);
}
} else {
a = c.obtainStyledAttributes(R.styleable.Text, 0);
}
resolveStyleAttrsForTypedArray(
a,
ellipsize,
extraSpacing,
shouldIncludeFontPadding,
spacingMultiplier,
minLines,
maxLines,
minEms,
maxEms,
minTextWidth,
maxTextWidth,
isSingleLine,
text,
textColorStateList,
linkColor,
highlightColor,
textSize,
textAlignment,
breakStrategy,
hyphenationFrequency,
justificationMode,
textStyle,
shadowRadius,
shadowDx,
shadowDy,
shadowColor,
verticalGravity,
typeface);
a.recycle();
}