Merge "Get color state list file content from PSI instead of disk" into mnc-ub-dev

This commit is contained in:
Jerome Gaillard
2016-01-11 18:06:10 +00:00
committed by Android (Google) Code Review

View File

@@ -327,12 +327,19 @@ public final class BridgeTypedArray extends TypedArray {
return null; 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); File f = new File(value);
if (f.isFile()) { if (f.isFile()) {
try { parser = ParserFactory.create(f);
XmlPullParser parser = ParserFactory.create(f); }
}
if (parser != null) {
BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser( BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(
parser, mContext, resValue.isFramework()); parser, mContext, resValue.isFramework());
try { try {
@@ -341,6 +348,7 @@ public final class BridgeTypedArray extends TypedArray {
} finally { } finally {
blockParser.ensurePopped(); blockParser.ensurePopped();
} }
}
} catch (XmlPullParserException e) { } catch (XmlPullParserException e) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, Bridge.getLog().error(LayoutLog.TAG_BROKEN,
"Failed to configure parser for " + value, e, null); "Failed to configure parser for " + value, e, null);
@@ -353,7 +361,6 @@ public final class BridgeTypedArray extends TypedArray {
return null; return null;
} }
}
try { try {
int color = ResourceHelper.getColor(value); int color = ResourceHelper.getColor(value);