@Test public void testReadCertsMultiArray() { List<List<byte[]>> result = FontResourcesParserCompat.readCerts(mResources, R.array.certarray); assertEquals(2, result.size()); List<byte[]> firstSet = result.get(0); assertEquals(2, firstSet.size()); String firstValue = Base64.encodeToString(firstSet.get(0), Base64.DEFAULT).trim(); assertEquals("MIIEqDCCA5CgAwIBAgIJANWFuGx9", firstValue); String secondValue = Base64.encodeToString(firstSet.get(1), Base64.DEFAULT).trim(); assertEquals("UEChMHQW5kcm9pZDEQMA4GA=", secondValue); List<byte[]> secondSet = result.get(1); assertEquals(2, secondSet.size()); String thirdValue = Base64.encodeToString(secondSet.get(0), Base64.DEFAULT).trim(); assertEquals("MDEyMzM2NTZaMIGUMQswCQYD", thirdValue); String fourthValue = Base64.encodeToString(secondSet.get(1), Base64.DEFAULT).trim(); assertEquals("DHThvbbR24kT9ixcOd9W+EY=", fourthValue); }
public static List<List<byte[]>> readCerts(Resources resources, @ArrayRes int certsId) { List<List<byte[]>> certs = null; if (certsId != 0) { TypedArray typedArray = resources.obtainTypedArray(certsId); if (typedArray.length() > 0) { certs = new ArrayList<>(); boolean isArrayOfArrays = typedArray.getResourceId(0, 0) != 0; if (isArrayOfArrays) { for (int i = 0; i < typedArray.length(); i++) { int certId = typedArray.getResourceId(i, 0); String[] certsArray = resources.getStringArray(certId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } else { String[] certsArray = resources.getStringArray(certsId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } typedArray.recycle(); } return certs != null ? certs : Collections.<List<byte[]>>emptyList(); }
FontResourcesParserCompat { public static List<List<byte[]>> readCerts(Resources resources, @ArrayRes int certsId) { List<List<byte[]>> certs = null; if (certsId != 0) { TypedArray typedArray = resources.obtainTypedArray(certsId); if (typedArray.length() > 0) { certs = new ArrayList<>(); boolean isArrayOfArrays = typedArray.getResourceId(0, 0) != 0; if (isArrayOfArrays) { for (int i = 0; i < typedArray.length(); i++) { int certId = typedArray.getResourceId(i, 0); String[] certsArray = resources.getStringArray(certId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } else { String[] certsArray = resources.getStringArray(certsId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } typedArray.recycle(); } return certs != null ? certs : Collections.<List<byte[]>>emptyList(); } }
FontResourcesParserCompat { public static List<List<byte[]>> readCerts(Resources resources, @ArrayRes int certsId) { List<List<byte[]>> certs = null; if (certsId != 0) { TypedArray typedArray = resources.obtainTypedArray(certsId); if (typedArray.length() > 0) { certs = new ArrayList<>(); boolean isArrayOfArrays = typedArray.getResourceId(0, 0) != 0; if (isArrayOfArrays) { for (int i = 0; i < typedArray.length(); i++) { int certId = typedArray.getResourceId(i, 0); String[] certsArray = resources.getStringArray(certId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } else { String[] certsArray = resources.getStringArray(certsId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } typedArray.recycle(); } return certs != null ? certs : Collections.<List<byte[]>>emptyList(); } private  FontResourcesParserCompat(); }
FontResourcesParserCompat { public static List<List<byte[]>> readCerts(Resources resources, @ArrayRes int certsId) { List<List<byte[]>> certs = null; if (certsId != 0) { TypedArray typedArray = resources.obtainTypedArray(certsId); if (typedArray.length() > 0) { certs = new ArrayList<>(); boolean isArrayOfArrays = typedArray.getResourceId(0, 0) != 0; if (isArrayOfArrays) { for (int i = 0; i < typedArray.length(); i++) { int certId = typedArray.getResourceId(i, 0); String[] certsArray = resources.getStringArray(certId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } else { String[] certsArray = resources.getStringArray(certsId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } typedArray.recycle(); } return certs != null ? certs : Collections.<List<byte[]>>emptyList(); } private  FontResourcesParserCompat(); static @Nullable FamilyResourceEntry parse(XmlPullParser parser, Resources resources); static List<List<byte[]>> readCerts(Resources resources, @ArrayRes int certsId); }
FontResourcesParserCompat { public static List<List<byte[]>> readCerts(Resources resources, @ArrayRes int certsId) { List<List<byte[]>> certs = null; if (certsId != 0) { TypedArray typedArray = resources.obtainTypedArray(certsId); if (typedArray.length() > 0) { certs = new ArrayList<>(); boolean isArrayOfArrays = typedArray.getResourceId(0, 0) != 0; if (isArrayOfArrays) { for (int i = 0; i < typedArray.length(); i++) { int certId = typedArray.getResourceId(i, 0); String[] certsArray = resources.getStringArray(certId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } else { String[] certsArray = resources.getStringArray(certsId); List<byte[]> certsList = toByteArrayList(certsArray); certs.add(certsList); } } typedArray.recycle(); } return certs != null ? certs : Collections.<List<byte[]>>emptyList(); } 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; }