@Test public void testParseAndroidAttrs() throws XmlPullParserException, IOException { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { return; } @SuppressLint("ResourceType") XmlResourceParser parser = mResources.getXml(R.font.samplexmlfontforparsing2); FamilyResourceEntry result = FontResourcesParserCompat.parse(parser, mResources); assertNotNull(result); FontFamilyFilesResourceEntry filesEntry = (FontFamilyFilesResourceEntry) result; FontFileResourceEntry[] fileEntries = filesEntry.getEntries(); assertEquals(4, fileEntries.length); FontFileResourceEntry font1 = fileEntries[0]; assertEquals(400, font1.getWeight()); assertEquals(false, font1.isItalic()); assertEquals("'wdth' 0.8", font1.getVariationSettings()); assertEquals(0, font1.getTtcIndex()); assertEquals(R.font.samplefont, font1.getResourceId()); FontFileResourceEntry font2 = fileEntries[1]; assertEquals(400, font2.getWeight()); assertEquals(true, font2.isItalic()); assertEquals("'contrast' 0.5", font2.getVariationSettings()); assertEquals(1, font2.getTtcIndex()); assertEquals(R.font.samplefont2, font2.getResourceId()); FontFileResourceEntry font3 = fileEntries[2]; assertEquals(700, font3.getWeight()); assertEquals(false, font3.isItalic()); assertEquals("'wdth' 500.0, 'wght' 300.0", font3.getVariationSettings()); assertEquals(2, font3.getTtcIndex()); assertEquals(R.font.samplefont3, font3.getResourceId()); FontFileResourceEntry font4 = fileEntries[3]; assertEquals(700, font4.getWeight()); assertEquals(true, font4.isItalic()); assertEquals(null, font4.getVariationSettings()); assertEquals(0, font4.getTtcIndex()); assertEquals(R.font.samplefont4, font4.getResourceId()); }
public static @Nullable FamilyResourceEntry parse(XmlPullParser parser, Resources resources) throws XmlPullParserException, IOException { int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { } if (type != XmlPullParser.START_TAG) { throw new XmlPullParserException("No start tag found"); } return readFamilies(parser, resources); }
FontResourcesParserCompat { public static @Nullable FamilyResourceEntry parse(XmlPullParser parser, Resources resources) throws XmlPullParserException, IOException { int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { } if (type != XmlPullParser.START_TAG) { throw new XmlPullParserException("No start tag found"); } return readFamilies(parser, resources); } }
FontResourcesParserCompat { public static @Nullable FamilyResourceEntry parse(XmlPullParser parser, Resources resources) throws XmlPullParserException, IOException { int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { } if (type != XmlPullParser.START_TAG) { throw new XmlPullParserException("No start tag found"); } return readFamilies(parser, resources); } private  FontResourcesParserCompat(); }
FontResourcesParserCompat { public static @Nullable FamilyResourceEntry parse(XmlPullParser parser, Resources resources) throws XmlPullParserException, IOException { int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { } if (type != XmlPullParser.START_TAG) { throw new XmlPullParserException("No start tag found"); } return readFamilies(parser, resources); } private  FontResourcesParserCompat(); static @Nullable FamilyResourceEntry parse(XmlPullParser parser, Resources resources); static List<List<byte[]>> readCerts(Resources resources, @ArrayRes int certsId); }
FontResourcesParserCompat { public static @Nullable FamilyResourceEntry parse(XmlPullParser parser, Resources resources) throws XmlPullParserException, IOException { int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { } if (type != XmlPullParser.START_TAG) { throw new XmlPullParserException("No start tag found"); } return readFamilies(parser, resources); } private  FontResourcesParserCompat(); static @Nullable FamilyResourceEntry parse(XmlPullParser parser, Resources resources); static List<List<byte[]>> readCerts(Resources resources, @ArrayRes int certsId); static final int FETCH_STRATEGY_BLOCKING; static final int FETCH_STRATEGY_ASYNC; static final int INFINITE_TIMEOUT_VALUE; }