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

Commit 95842c88 authored by Diego Perez's avatar Diego Perez Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE when using "view" tag without class attribute"

parents 2292214a e852d199
Loading
Loading
Loading
Loading
+22 −2
Original line number Original line Diff line number Diff line
@@ -144,9 +144,26 @@ public final class BridgeInflater extends LayoutInflater {
    @Override
    @Override
    public View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
    public View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
            boolean ignoreThemeAttr) {
            boolean ignoreThemeAttr) {
        View view;
        View view = null;
        if (name.equals("view")) {
            // This is usually done by the superclass but this allows us catching the error and
            // reporting something useful.
            name = attrs.getAttributeValue(null, "class");

            if (name == null) {
                Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Unable to inflate view tag without " +
                  "class attribute", null);
                // We weren't able to resolve the view so we just pass a mock View to be able to
                // continue rendering.
                view = new MockView(context, attrs);
                ((MockView) view).setText("view");
            }
        }

        try {
        try {
            if (view == null) {
                view = super.createViewFromTag(parent, name, context, attrs, ignoreThemeAttr);
                view = super.createViewFromTag(parent, name, context, attrs, ignoreThemeAttr);
            }
        } catch (InflateException e) {
        } catch (InflateException e) {
            // Creation of ContextThemeWrapper code is same as in the super method.
            // Creation of ContextThemeWrapper code is same as in the super method.
            // Apply a theme wrapper, if allowed and one is specified.
            // Apply a theme wrapper, if allowed and one is specified.
@@ -240,6 +257,9 @@ public final class BridgeInflater extends LayoutInflater {
            // first get the classname in case it's not the node name
            // first get the classname in case it's not the node name
            if (name.equals("view")) {
            if (name.equals("view")) {
                name = attrs.getAttributeValue(null, "class");
                name = attrs.getAttributeValue(null, "class");
                if (name == null) {
                    return null;
                }
            }
            }


            mConstructorArgs[1] = attrs;
            mConstructorArgs[1] = attrs;