From d758e042ce08c46712db3db2d63fc84795028dfe Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Thu, 28 May 2015 12:33:04 -0700 Subject: [PATCH] Fix NPE in BridgeContext.obtainStyledAttributes() Replace direct member access with getter that checks for nullness. Change-Id: I4a56a0ee903ae7d8c89b91d74b128302e1965586 --- .../com/android/layoutlib/bridge/android/BridgeContext.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index 9d2b884066caa..f03ec58f325ac 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -130,6 +130,7 @@ public final class BridgeContext extends Context { new IdentityHashMap>(); // maps for dynamically generated id representing style objects (StyleResourceValue) + @Nullable private Map mDynamicIdToStyleMap; private Map mStyleToDynamicIdMap; private int mDynamicIdGenerator = 0x02030000; // Base id for R.style in custom namespace @@ -727,7 +728,7 @@ public final class BridgeContext extends Context { } } } else if (defStyleRes != 0) { - StyleResourceValue item = mDynamicIdToStyleMap.get(defStyleRes); + StyleResourceValue item = getStyleByDynamicId(defStyleRes); if (item != null) { defStyleValues = item; } else {