Skip to content

Commit

Permalink
Adds text style to cache on content create
Browse files Browse the repository at this point in the history
Summary: Adds text style to cache on content create

Reviewed By: AlexBalo

Differential Revision: D55472290

fbshipit-source-id: b28e6c673f0aced18beab6e1b662ef7d28fab8c1
  • Loading branch information
adityasharat authored and facebook-github-bot committed Mar 28, 2024
1 parent 691ce59 commit 424eb96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import androidx.core.text.TextDirectionHeuristicsCompat;

public class TextStyle implements Cloneable {

static final int UNSET = -1;
@Nullable TextUtils.TruncateAt ellipsize;
@Nullable CharSequence customEllipsisText;
Expand Down Expand Up @@ -288,7 +289,12 @@ public void setLetterSpacing(float letterSpacing) {
this.letterSpacing = letterSpacing;
}

public static void addThemedTextStyleForContextToCache(Context context) {
TextStylesAttributeHelper.addThemedTextStyleForContext(context);
}

public static class RoundedBackgroundProps {

final RectF padding;
final float cornerRadius;
final @ColorInt int backgroundColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class TextStylesAttributeHelper {
private static final WeakHashMap<Resources.Theme, TextStyle> sThemedRenderUnitCache =
new WeakHashMap<>();

public static TextStyle createThemedTextStyle(Context c) {
private static TextStyle getThemedTextStyleFromCache(Context c) {
final Resources.Theme theme = c.getTheme();
TextStyle textStyle;

Expand All @@ -71,7 +71,15 @@ public static TextStyle createThemedTextStyle(Context c) {
}
}

return textStyle.makeCopy();
return textStyle;
}

public static void addThemedTextStyleForContext(Context c) {
getThemedTextStyleFromCache(c);
}

public static TextStyle createThemedTextStyle(Context c) {
return getThemedTextStyleFromCache(c).makeCopy();
}

public static void warmTextForTheme(Context c) {
Expand Down

0 comments on commit 424eb96

Please sign in to comment.