From f627cbb15b5ffc8e1195dfd1dde751a9202e11e1 Mon Sep 17 00:00:00 2001 From: Diego Perez Date: Fri, 29 Jul 2016 10:31:37 +0100 Subject: [PATCH] Try to resolve IDs also as enums This is intended to cover the edge case in ConstraintLayout (and possibly in other places) where an attribute is defined as reference|enum. If we can not resolve the value as a reference, try to resolve it as an enum and return the value. Change-Id: I2817aa5d78500247a2e9aec5411586a1db13791d (cherry picked from commit b24b563654bf7c007f0912bf32fbab948fcb6daa) --- .../src/android/content/res/BridgeTypedArray.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java index 1d5ac0ca7346b..9da65a60a3191 100644 --- a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java +++ b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java @@ -638,7 +638,15 @@ public final class BridgeTypedArray extends TypedArray { } } - // not a direct id valid reference? resolve it + // not a direct id valid reference. First check if it's an enum (this is a corner case + // for attributes that have a reference|enum type), then fallback to resolve + // as an ID without prefix. + Integer enumValue = resolveEnumAttribute(index); + if (enumValue != null) { + return enumValue; + } + + // Ok, not an enum, resolve as an ID Integer idValue; if (resValue.isFramework()) {