summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2015-01-31 04:17:35 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-01-31 04:17:35 +0000
commit6a439908fcc103696dd90bc42494231b54b7a10b (patch)
tree4499f32ab5c0b9c791d143e1ac7f28d4a116b2c5
parent52c39c27e9f5fde74e2d326c6a3560334fbea926 (diff)
parent862cdd6f11490c060842599a58a400e284c937d9 (diff)
downloadframeworks_base-6a439908fcc103696dd90bc42494231b54b7a10b.zip
frameworks_base-6a439908fcc103696dd90bc42494231b54b7a10b.tar.gz
frameworks_base-6a439908fcc103696dd90bc42494231b54b7a10b.tar.bz2
am 1d59871e: Merge "Resource resolution fixes." into lmp-dev automerge: 7e683bd automerge: 1575ca6
automerge: 862cdd6 * commit '862cdd6f11490c060842599a58a400e284c937d9': Resource resolution fixes.
-rw-r--r--tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java26
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java6
2 files changed, 24 insertions, 8 deletions
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
index a2bd6d7..1803692 100644
--- a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
@@ -614,15 +614,27 @@ public final class BridgeTypedArray extends TypedArray {
int pos = value.indexOf('/');
String idName = value.substring(pos + 1);
-
- // if this is a framework id
- if (mPlatformFile || value.startsWith("@android") || value.startsWith("@+android")) {
- // look for idName in the android R classes
+ boolean create = value.startsWith("@+");
+ boolean isFrameworkId =
+ mPlatformFile || value.startsWith("@android") || value.startsWith("@+android");
+
+ // Look for the idName in project or android R class depending on isPlatform.
+ if (create) {
+ Integer idValue;
+ if (isFrameworkId) {
+ idValue = Bridge.getResourceId(ResourceType.ID, idName);
+ } else {
+ idValue = mContext.getProjectCallback().getResourceId(ResourceType.ID, idName);
+ }
+ return idValue == null ? defValue : idValue;
+ }
+ // This calls the same method as in if(create), but doesn't create a dynamic id, if
+ // one is not found.
+ if (isFrameworkId) {
return mContext.getFrameworkResourceValue(ResourceType.ID, idName, defValue);
+ } else {
+ return mContext.getProjectResourceValue(ResourceType.ID, idName, defValue);
}
-
- // look for idName in the project R class.
- return mContext.getProjectResourceValue(ResourceType.ID, idName, defValue);
}
// not a direct id valid reference? resolve it
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 3953624..3441878 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
@@ -289,6 +289,11 @@ public final class BridgeContext extends Context {
value = mRenderResources.resolveResValue(value);
}
+ if (value == null) {
+ // unable to find the attribute.
+ return false;
+ }
+
// check if this is a style resource
if (value instanceof StyleResourceValue) {
// get the id that will represent this style.
@@ -296,7 +301,6 @@ public final class BridgeContext extends Context {
return true;
}
-
int a;
// if this is a framework value.
if (value.isFramework()) {