package androidx.core.graphics; import android.graphics.Typeface; import androidx.annotation.RequiresApi; import androidx.annotation.RestrictTo; import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @RequiresApi(28) @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public class TypefaceCompatApi28Impl extends TypefaceCompatApi26Impl { private static final String CREATE_FROM_FAMILIES_WITH_DEFAULT_METHOD = "createFromFamiliesWithDefault"; private static final String DEFAULT_FAMILY = "sans-serif"; private static final int RESOLVE_BY_FONT_TABLE = -1; @Override // androidx.core.graphics.TypefaceCompatApi26Impl public Typeface createFromFamiliesWithDefault(Object obj) { try { Object newInstance = Array.newInstance(this.mFontFamily, 1); Array.set(newInstance, 0, obj); return (Typeface) this.mCreateFromFamiliesWithDefault.invoke(null, newInstance, "sans-serif", -1, -1); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } } @Override // androidx.core.graphics.TypefaceCompatApi26Impl public Method obtainCreateFromFamiliesWithDefaultMethod(Class cls) throws NoSuchMethodException { Class cls2 = Integer.TYPE; Method declaredMethod = Typeface.class.getDeclaredMethod("createFromFamiliesWithDefault", Array.newInstance(cls, 1).getClass(), String.class, cls2, cls2); declaredMethod.setAccessible(true); return declaredMethod; } }