diff options
Diffstat (limited to 'android/support/v7/widget/AppCompatTextHelper.java')
-rw-r--r-- | android/support/v7/widget/AppCompatTextHelper.java | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/android/support/v7/widget/AppCompatTextHelper.java b/android/support/v7/widget/AppCompatTextHelper.java index fa6196f5..51510aa2 100644 --- a/android/support/v7/widget/AppCompatTextHelper.java +++ b/android/support/v7/widget/AppCompatTextHelper.java @@ -29,7 +29,6 @@ import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.RequiresApi; import android.support.annotation.RestrictTo; -import android.support.v4.content.res.ResourcesCompat; import android.support.v4.widget.TextViewCompat; import android.support.v7.appcompat.R; import android.text.method.PasswordTransformationMethod; @@ -37,8 +36,6 @@ import android.util.AttributeSet; import android.util.TypedValue; import android.widget.TextView; -import java.lang.ref.WeakReference; - @RequiresApi(9) class AppCompatTextHelper { @@ -66,7 +63,6 @@ class AppCompatTextHelper { private int mStyle = Typeface.NORMAL; private Typeface mFontTypeface; - private boolean mAsyncFontPending; AppCompatTextHelper(TextView view) { mView = view; @@ -217,23 +213,8 @@ class AppCompatTextHelper { ? R.styleable.TextAppearance_android_fontFamily : R.styleable.TextAppearance_fontFamily; if (!context.isRestricted()) { - final WeakReference<TextView> textViewWeak = new WeakReference<>(mView); - ResourcesCompat.FontCallback replyCallback = new ResourcesCompat.FontCallback() { - @Override - public void onFontRetrieved(@NonNull Typeface typeface) { - onAsyncTypefaceReceived(textViewWeak, typeface); - } - - @Override - public void onFontRetrievalFailed(int reason) { - // Do nothing. - } - }; try { - // Note the callback will be triggered on the UI thread. - mFontTypeface = a.getFont(fontFamilyId, mStyle, replyCallback); - // If this call gave us an immediate result, ignore any pending callbacks. - mAsyncFontPending = mFontTypeface == null; + mFontTypeface = a.getFont(fontFamilyId, mStyle); } catch (UnsupportedOperationException | Resources.NotFoundException e) { // Expected if it is not a font resource. } @@ -241,16 +222,12 @@ class AppCompatTextHelper { if (mFontTypeface == null) { // Try with String. This is done by TextView JB+, but fails in ICS String fontFamilyName = a.getString(fontFamilyId); - if (fontFamilyName != null) { - mFontTypeface = Typeface.create(fontFamilyName, mStyle); - } + mFontTypeface = Typeface.create(fontFamilyName, mStyle); } return; } if (a.hasValue(R.styleable.TextAppearance_android_typeface)) { - // Ignore previous pending fonts - mAsyncFontPending = false; int typefaceIndex = a.getInt(R.styleable.TextAppearance_android_typeface, SANS); switch (typefaceIndex) { case SANS: @@ -268,16 +245,6 @@ class AppCompatTextHelper { } } - private void onAsyncTypefaceReceived(WeakReference<TextView> textViewWeak, Typeface typeface) { - if (mAsyncFontPending) { - mFontTypeface = typeface; - final TextView textView = textViewWeak.get(); - if (textView != null) { - textView.setTypeface(typeface, mStyle); - } - } - } - void onSetTextAppearance(Context context, int resId) { final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, resId, R.styleable.TextAppearance); |