aboutsummaryrefslogtreecommitdiffstats
path: root/ide_common/src/com/android/ide/common/rendering
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-01-27 18:05:56 -0800
committerXavier Ducrohet <xav@android.com>2011-01-28 12:42:05 -0800
commit3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed (patch)
tree72a0de0eda8b085d7038a3987ef23d1a05000654 /ide_common/src/com/android/ide/common/rendering
parent40826f2c5a850a1c0b74ec6193181383175f20cf (diff)
downloadsdk-3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed.zip
sdk-3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed.tar.gz
sdk-3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed.tar.bz2
Change APIs using String instead of ResourceType.
Move ResourceType into resources.jar so that it's accessible to layoutlib.jar This is cleaner and allows us to us more efficient EnumMap objects. Change-Id: If11cbc69ae3ca8bd6c96e6d0ef402570a07af16f
Diffstat (limited to 'ide_common/src/com/android/ide/common/rendering')
-rw-r--r--ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java b/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java
index bd72632..6fe7f10 100644
--- a/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java
+++ b/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java
@@ -23,6 +23,7 @@ import com.android.ide.common.rendering.api.ILayoutPullParser;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.Params;
import com.android.ide.common.rendering.api.RenderSession;
+import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.ViewInfo;
import com.android.ide.common.rendering.api.Params.RenderingMode;
@@ -38,6 +39,7 @@ import com.android.layoutlib.api.IProjectCallback;
import com.android.layoutlib.api.IResourceValue;
import com.android.layoutlib.api.IXmlPullParser;
import com.android.layoutlib.api.ILayoutResult.ILayoutViewInfo;
+import com.android.resources.ResourceType;
import java.io.File;
import java.lang.reflect.Constructor;
@@ -46,7 +48,9 @@ import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
/**
* Class to use the Layout library.
@@ -371,12 +375,11 @@ public class LayoutLibrary {
// convert the map of ResourceValue into IResourceValue. Super ugly but works.
- @SuppressWarnings("unchecked")
- Map<String, Map<String, IResourceValue>> projectMap =
- (Map<String, Map<String, IResourceValue>>)(Map) resources.getProjectResources();
- @SuppressWarnings("unchecked")
- Map<String, Map<String, IResourceValue>> frameworkMap =
- (Map<String, Map<String, IResourceValue>>)(Map) resources.getFrameworkResources();
+
+ Map<String, Map<String, IResourceValue>> projectMap = convertMap(
+ resources.getProjectResources());
+ Map<String, Map<String, IResourceValue>> frameworkMap = convertMap(
+ resources.getFrameworkResources());
ILayoutResult result = null;
@@ -434,6 +437,21 @@ public class LayoutLibrary {
return convertToScene(result);
}
+ @SuppressWarnings("unchecked")
+ private Map<String, Map<String, IResourceValue>> convertMap(
+ Map<ResourceType, Map<String, ResourceValue>> map) {
+ Map<String, Map<String, IResourceValue>> result =
+ new HashMap<String, Map<String, IResourceValue>>();
+
+ for (Entry<ResourceType, Map<String, ResourceValue>> entry : map.entrySet()) {
+ // ugly case but works.
+ result.put(entry.getKey().getName(),
+ (Map<String, IResourceValue>)(Map) entry.getValue());
+ }
+
+ return result;
+ }
+
/**
* Converts a {@link ILayoutResult} to a {@link RenderSession}.
*/