Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b63da06a authored by Jerome Gaillard's avatar Jerome Gaillard
Browse files

Get color state list file content from PSI instead of disk

Use new functionality from callback to get the content of state list files
from PSI instead of disks.

Bug: http://b.android.com/183767
Change-Id: Ic256d1e7787209d772ccd42c2e3c7f409cac2964
parent 4b0fe7f1
Loading
Loading
Loading
Loading
+23 −16
Original line number Diff line number Diff line
@@ -327,12 +327,19 @@ public final class BridgeTypedArray extends TypedArray {
            return null;
        }

        // let the framework inflate the ColorStateList from the XML file.

        try {
            // Get the state list file content from callback to parse PSI file
            XmlPullParser parser = mContext.getLayoutlibCallback().getXmlFileParser(value);
            if (parser == null) {
                // If used with a version of Android Studio that does not implement getXmlFileParser
                // fall back to reading the file from disk
                File f = new File(value);
                if (f.isFile()) {
            try {
                XmlPullParser parser = ParserFactory.create(f);

                    parser = ParserFactory.create(f);
                }
            }
            if (parser != null) {
                BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(
                        parser, mContext, resValue.isFramework());
                try {
@@ -341,6 +348,7 @@ public final class BridgeTypedArray extends TypedArray {
                } finally {
                    blockParser.ensurePopped();
                }
            }
        } catch (XmlPullParserException e) {
            Bridge.getLog().error(LayoutLog.TAG_BROKEN,
                    "Failed to configure parser for " + value, e, null);
@@ -353,7 +361,6 @@ public final class BridgeTypedArray extends TypedArray {

            return null;
        }
        }

        try {
            int color = ResourceHelper.getColor(value);