File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed
lib/java/com/google/android/material Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -276,7 +276,7 @@ private BadgeDrawable(Context context) {
276276 badgeWidePadding = res .getDimensionPixelSize (R .dimen .mtrl_badge_long_text_horizontal_padding );
277277 badgeWithTextRadius = res .getDimensionPixelSize (R .dimen .mtrl_badge_with_text_radius );
278278
279- textDrawableHelper = new TextDrawableHelper ();
279+ textDrawableHelper = new TextDrawableHelper (/* delegate= */ this );
280280 textDrawableHelper .getTextPaint ().setTextAlign (Paint .Align .CENTER );
281281 this .savedState = new SavedState (context );
282282 setTextAppearanceResource (R .style .TextAppearance_MaterialComponents_Badge );
Original file line number Diff line number Diff line change @@ -330,7 +330,7 @@ private ChipDrawable(
330330 initializeElevationOverlay (context );
331331
332332 this .context = context ;
333- textDrawableHelper = new TextDrawableHelper ();
333+ textDrawableHelper = new TextDrawableHelper (/* delegate= */ this );
334334
335335 text = "" ;
336336
Original file line number Diff line number Diff line change @@ -70,6 +70,13 @@ public void onFontRetrievalFailed(int reason) {
7070 private WeakReference <TextDrawableDelegate > delegate = new WeakReference <>(null );
7171 @ Nullable private TextAppearance textAppearance ;
7272
73+ /**
74+ * Please provide a delegate if your text font may load asynchronously.
75+ */
76+ public TextDrawableHelper (@ Nullable TextDrawableDelegate delegate ) {
77+ setDelegate (delegate );
78+ }
79+
7380 /** Sets the delegate that owns this TextDrawableHelper. */
7481 public void setDelegate (@ Nullable TextDrawableDelegate delegate ) {
7582 this .delegate = new WeakReference <>(delegate );
You can’t perform that action at this time.
0 commit comments