Merge "Workaround crash when calling 'new Path(null)'" into master-layoutlib-native
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/LayoutParserWrapper.java b/bridge/src/com/android/layoutlib/bridge/impl/LayoutParserWrapper.java
index 71e7fd2..8c3b128 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/LayoutParserWrapper.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/LayoutParserWrapper.java
@@ -49,6 +49,7 @@
private List<Attribute> mAttributes;
private String mText;
private String mName;
+ private boolean mIsWhitespace;
// Used to end the document before the actual parser ends.
private int mFinalDepth = -1;
@@ -119,6 +120,7 @@
mDepth = mDelegate.getDepth();
mText = mDelegate.getText();
mName = mDelegate.getName();
+ mIsWhitespace = mNext == TEXT && mDelegate.isWhitespace();
mPeeked = true;
return mNext;
}
@@ -203,6 +205,11 @@
return returnValue;
}
+ @Override
+ public boolean isWhitespace() throws XmlPullParserException {
+ return mPeeked ? mIsWhitespace : mDelegate.isWhitespace();
+ }
+
private static class Attribute {
@Nullable
public final String namespace;
@@ -311,11 +318,6 @@
}
@Override
- public boolean isWhitespace() throws XmlPullParserException {
- throw new UnsupportedOperationException("Only few parser methods are supported.");
- }
-
- @Override
public char[] getTextCharacters(int[] ints) {
throw new UnsupportedOperationException("Only few parser methods are supported.");
}