public static void updateFromStyleResource()

in library/src/main/java/com/facebook/fbui/textlayoutbuilder/ResourceTextLayoutHelper.java [69:146]


  public static void updateFromStyleResource(
      TextLayoutBuilder builder,
      Context context,
      AttributeSet attrs,
      @AttrRes int styleAttr,
      @StyleRes int styleRes) {
    TypedArray customAttrs =
        context.obtainStyledAttributes(attrs, R.styleable.TextStyle, styleAttr, styleRes);

    int textAppearanceId =
        customAttrs.getResourceId(R.styleable.TextStyle_android_textAppearance, -1);

    if (textAppearanceId > 0) {
      setTextAppearance(builder, context, textAppearanceId);
    }

    ColorStateList textColor =
        customAttrs.getColorStateList(R.styleable.TextStyle_android_textColor);

    int textSize =
        customAttrs.getDimensionPixelSize(
            R.styleable.TextStyle_android_textSize, DEFAULT_TEXT_SIZE_PX);

    int shadowColor =
        customAttrs.getInt(R.styleable.TextStyle_android_shadowColor, Color.TRANSPARENT);

    float dx = customAttrs.getFloat(R.styleable.TextStyle_android_shadowDx, 0.0f);

    float dy = customAttrs.getFloat(R.styleable.TextStyle_android_shadowDy, 0.0f);

    float radius = customAttrs.getFloat(R.styleable.TextStyle_android_shadowRadius, 0.0f);

    int textStyle = customAttrs.getInt(R.styleable.TextStyle_android_textStyle, -1);

    int ellipsize = customAttrs.getInt(R.styleable.TextStyle_android_ellipsize, 0);

    boolean singleLine = customAttrs.getBoolean(R.styleable.TextStyle_android_singleLine, false);

    int maxLines =
        customAttrs.getInt(
            R.styleable.TextStyle_android_maxLines, TextLayoutBuilder.DEFAULT_MAX_LINES);

    int breakStrategy = customAttrs.getInt(R.styleable.TextStyle_android_breakStrategy, -1);

    int hyphenationFrequency =
        customAttrs.getInt(R.styleable.TextStyle_android_hyphenationFrequency, -1);

    customAttrs.recycle();

    builder.setTextColor(textColor);

    builder.setTextSize(textSize);
    builder.setShadowLayer(radius, dx, dy, shadowColor);

    if (textStyle != -1) {
      builder.setTypeface(Typeface.defaultFromStyle(textStyle));
    } else {
      builder.setTypeface(null);
    }

    if (ellipsize > 0 && ellipsize < 4) {
      // TruncateAt doesn't have a value for NONE.
      builder.setEllipsize(TextUtils.TruncateAt.values()[ellipsize - 1]);
    } else {
      builder.setEllipsize(null);
    }

    builder.setSingleLine(singleLine);
    builder.setMaxLines(maxLines);

    if (breakStrategy > -1) {
      builder.setBreakStrategy(breakStrategy);
    }

    if (hyphenationFrequency > -1) {
      builder.setHyphenationFrequency(hyphenationFrequency);
    }
  }