Address warnings in BridgeXmlBlockParser + annotations

Test: N/A
Change-Id: I3c56858ad9d86c41e1b5709bd4868b716f6255a1
diff --git a/bridge/src/android/util/BridgeXmlPullAttributes.java b/bridge/src/android/util/BridgeXmlPullAttributes.java
index 9fd1e15..f1af1d1 100644
--- a/bridge/src/android/util/BridgeXmlPullAttributes.java
+++ b/bridge/src/android/util/BridgeXmlPullAttributes.java
@@ -295,7 +295,7 @@
     private int resolveResourceValue(String value, int defaultValue) {
         ResourceValue resource = getResourceValue(value);
         if (resource != null) {
-            Integer id = null;
+            Integer id;
             if (mPlatformFile || resource.isFramework()) {
                 id = Bridge.getResourceId(resource.getResourceType(), resource.getName());
             } else {
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java b/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
index ac8712e..f18cd48 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
@@ -23,6 +23,8 @@
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
+import android.annotation.NonNull;
+import android.annotation.Nullable;
 import android.content.res.XmlResourceParser;
 import android.util.AttributeSet;
 import android.util.BridgeXmlPullAttributes;
@@ -39,7 +41,7 @@
 public class BridgeXmlBlockParser implements XmlResourceParser {
 
     private final XmlPullParser mParser;
-    private final BridgeXmlPullAttributes mAttrib;
+    private final AttributeSet mAttrib;
     private final BridgeContext mContext;
     private final boolean mPlatformFile;
 
@@ -54,7 +56,8 @@
      * @param context the Context.
      * @param platformFile Indicates whether the the file is a platform file or not.
      */
-    public BridgeXmlBlockParser(XmlPullParser parser, BridgeContext context, boolean platformFile) {
+    public BridgeXmlBlockParser(@NonNull XmlPullParser parser, @Nullable BridgeContext context,
+            boolean platformFile) {
         if (ParserFactory.LOG_PARSER) {
             System.out.println("CRTE " + parser.toString());
         }
@@ -62,12 +65,15 @@
         mParser = parser;
         mContext = context;
         mPlatformFile = platformFile;
-        mAttrib = new BridgeXmlPullAttributes(parser, context, mPlatformFile);
 
         if (mContext != null) {
+            mAttrib = new BridgeXmlPullAttributes(parser, context, mPlatformFile);
             mContext.pushParser(this);
             mPopped = false;
         }
+        else {
+            mAttrib = new NopAttributeSet();
+        }
     }
 
     public XmlPullParser getParser() {
@@ -87,7 +93,7 @@
     }
 
     public void ensurePopped() {
-        if (mContext != null && mPopped == false) {
+        if (mContext != null && !mPopped) {
             mContext.popParser();
             mPopped = true;
         }
@@ -109,13 +115,8 @@
 
     @Override
     public boolean getFeature(String name) {
-        if (FEATURE_PROCESS_NAMESPACES.equals(name)) {
-            return true;
-        }
-        if (FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
-            return true;
-        }
-        return false;
+        return FEATURE_PROCESS_NAMESPACES.equals(name) ||
+                FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name);
     }
 
     @Override
@@ -318,7 +319,7 @@
         return ev;
     }
 
-    public static String eventTypeToString(int eventType) {
+    private static String eventTypeToString(int eventType) {
         switch (eventType) {
             case START_DOCUMENT:
                 return "START_DOC";
@@ -491,4 +492,5 @@
     public int getStyleAttribute() {
         return mAttrib.getStyleAttribute();
     }
+
 }
diff --git a/bridge/src/com/android/layoutlib/bridge/android/NopAttributeSet.java b/bridge/src/com/android/layoutlib/bridge/android/NopAttributeSet.java
new file mode 100644
index 0000000..fbb12d5
--- /dev/null
+++ b/bridge/src/com/android/layoutlib/bridge/android/NopAttributeSet.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.android;
+
+import android.util.AttributeSet;
+
+/**
+ * Empty {@link AttributeSet}
+ */
+class NopAttributeSet implements AttributeSet {
+    @Override
+    public int getAttributeCount() {
+        return 0;
+    }
+
+    @Override
+    public String getAttributeName(int index) {
+        return null;
+    }
+
+    @Override
+    public String getAttributeValue(int index) {
+        return null;
+    }
+
+    @Override
+    public String getAttributeValue(String namespace, String name) {
+        return null;
+    }
+
+    @Override
+    public String getPositionDescription() {
+        return null;
+    }
+
+    @Override
+    public int getAttributeNameResource(int index) {
+        return 0;
+    }
+
+    @Override
+    public int getAttributeListValue(String namespace, String attribute, String[] options, int
+            defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public boolean getAttributeBooleanValue(String namespace, String attribute,
+            boolean defaultValue) {
+        return false;
+    }
+
+    @Override
+    public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public int getAttributeIntValue(String namespace, String attribute, int defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public int getAttributeUnsignedIntValue(String namespace, String attribute,
+            int defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public float getAttributeFloatValue(String namespace, String attribute,
+            float defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public int getAttributeListValue(int index, String[] options, int defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public boolean getAttributeBooleanValue(int index, boolean defaultValue) {
+        return false;
+    }
+
+    @Override
+    public int getAttributeResourceValue(int index, int defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public int getAttributeIntValue(int index, int defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public int getAttributeUnsignedIntValue(int index, int defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public float getAttributeFloatValue(int index, float defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public String getIdAttribute() {
+        return null;
+    }
+
+    @Override
+    public String getClassAttribute() {
+        return null;
+    }
+
+    @Override
+    public int getIdAttributeResourceValue(int defaultValue) {
+        return 0;
+    }
+
+    @Override
+    public int getStyleAttribute() {
+        return 0;
+    }
+}