diff options
| -rw-r--r-- | core/java/android/content/res/Resources.java | 13 | ||||
| -rw-r--r-- | core/java/android/content/res/ResourcesImpl.java | 40 |
2 files changed, 7 insertions, 46 deletions
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 21d4b2277a8e..3693bce91d70 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -375,14 +375,15 @@ public class Resources { /** * @hide */ - public void preloadFonts(@FontRes int id) { - final TypedValue value = obtainTempTypedValue(); + public void preloadFonts(@ArrayRes int id) { + final TypedArray array = obtainTypedArray(id); try { - final ResourcesImpl impl = mResourcesImpl; - impl.getValue(id, value, true); - impl.preloadFonts(this, value, id); + final int size = array.length(); + for (int i = 0; i < size; i++) { + array.getFont(i); + } } finally { - releaseTempTypedValue(value); + array.recycle(); } } diff --git a/core/java/android/content/res/ResourcesImpl.java b/core/java/android/content/res/ResourcesImpl.java index ccf30acc4d68..f9acab97b40b 100644 --- a/core/java/android/content/res/ResourcesImpl.java +++ b/core/java/android/content/res/ResourcesImpl.java @@ -787,46 +787,6 @@ public class ResourcesImpl { } /** - * @hide - */ - public void preloadFonts(Resources wrapper, TypedValue value, int id) { - if (value.string == null) { - throw new NotFoundException("Resource \"" + getResourceName(id) + "\" (" - + Integer.toHexString(id) + ") is not a Font: " + value); - } - - final String file = value.string.toString(); - - Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, file); - try { - // TODO: Stop re-ussing font-family xml tag structure and use ResourceArray instead. - final XmlResourceParser rp = loadXmlResourceParser( - file, id, value.assetCookie, "font"); - final FontResourcesParser.FamilyResourceEntry familyEntry = - FontResourcesParser.parse(rp, wrapper); - if (familyEntry == null) { - Log.e(TAG, "failed to find font-family tag"); - return; - } - if (familyEntry instanceof FontResourcesParser.ProviderResourceEntry) { - throw new IllegalArgumentException("Provider based fonts can not be used."); - } - final FontResourcesParser.FontFamilyFilesResourceEntry filesEntry = - (FontResourcesParser.FontFamilyFilesResourceEntry) familyEntry; - for (FontResourcesParser.FontFileResourceEntry fileEntry : filesEntry.getEntries()) { - int resourceId = fileEntry.getResourceId(); - wrapper.getFont(resourceId); - } - } catch (XmlPullParserException e) { - Log.e(TAG, "Failed to parse xml resource " + file, e); - } catch (IOException e) { - Log.e(TAG, "Failed to read xml resource " + file, e); - } finally { - Trace.traceEnd(Trace.TRACE_TAG_RESOURCES); - } - } - - /** * Given the value and id, we can get the XML filename as in value.data, based on that, we * first try to load CSL from the cache. If not found, try to get from the constant state. * Last, parse the XML and generate the CSL. |