diff options
author | Xavier Ducrohet <xav@android.com> | 2011-01-27 18:05:56 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-01-28 12:42:05 -0800 |
commit | 3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed (patch) | |
tree | 72a0de0eda8b085d7038a3987ef23d1a05000654 /layoutlib_api/src/com | |
parent | 40826f2c5a850a1c0b74ec6193181383175f20cf (diff) | |
download | sdk-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 'layoutlib_api/src/com')
5 files changed, 25 insertions, 24 deletions
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java index 4d0d51f..12bd57c 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java @@ -17,13 +17,14 @@ package com.android.ide.common.rendering.api; import com.android.layoutlib.api.IDensityBasedResourceValue; +import com.android.resources.ResourceType; @SuppressWarnings("deprecation") public class DensityBasedResourceValue extends ResourceValue implements IDensityBasedResourceValue { private com.android.resources.Density mDensity; - public DensityBasedResourceValue(String type, String name, String value, + public DensityBasedResourceValue(ResourceType type, String name, String value, com.android.resources.Density density, boolean isFramework) { super(type, name, value, isFramework); mDensity = density; diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java b/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java index 67e082e..aebc5a5 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java @@ -16,6 +16,8 @@ package com.android.ide.common.rendering.api; +import com.android.resources.ResourceType; + /** * Callback for project information needed by the Layout Library. * Classes implementing this interface provide methods giving access to some project data, like @@ -69,6 +71,6 @@ public interface IProjectCallback { * @param name the name of the resource * @return an Integer containing the resource Id, or <code>null</code> if not found. */ - Integer getResourceValue(String type, String name); + Integer getResourceValue(ResourceType type, String name); } diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java index ce86c9a..ea572bc 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java @@ -16,6 +16,8 @@ package com.android.ide.common.rendering.api; +import com.android.resources.ResourceType; + /** * A class containing all the resources needed to do a rendering. * <p/> @@ -24,21 +26,10 @@ package com.android.ide.common.rendering.api; */ public class RenderResources { - public final static String RES_ANIMATOR = "animator"; - public final static String RES_STYLE = "style"; - public final static String RES_ATTR = "attr"; - public final static String RES_DIMEN = "dimen"; - public final static String RES_DRAWABLE = "drawable"; - public final static String RES_COLOR = "color"; - public final static String RES_LAYOUT = "layout"; - public final static String RES_STRING = "string"; - public final static String RES_ID = "id"; - public final static String REFERENCE_NULL = "@null"; - public static class FrameworkResourceIdProvider { - public Integer getId(String resType, String resName) { + public Integer getId(ResourceType resType, String resName) { return null; } } @@ -83,7 +74,7 @@ public class RenderResources { * @param resourceType the type of the resource * @param resourceName the name of the resource */ - public ResourceValue getFrameworkResource(String resourceType, String resourceName) { + public ResourceValue getFrameworkResource(ResourceType resourceType, String resourceName) { return null; } @@ -92,7 +83,7 @@ public class RenderResources { * @param resourceType the type of the resource * @param resourceName the name of the resource */ - public ResourceValue getProjectResource(String resourceType, String resourceName) { + public ResourceValue getProjectResource(ResourceType resourceType, String resourceName) { return null; } @@ -165,7 +156,7 @@ public class RenderResources { * * @return the resolved resource value or <code>null</code> if it failed to resolve it. */ - public ResourceValue resolveValue(String type, String name, String value, + public ResourceValue resolveValue(ResourceType type, String name, String value, boolean isFrameworkValue) { return null; } diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java index f59f3c3..76561c8 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java @@ -17,35 +17,41 @@ package com.android.ide.common.rendering.api; import com.android.layoutlib.api.IResourceValue; +import com.android.resources.ResourceType; /** * Represents an android resource with a name and a string value. */ @SuppressWarnings("deprecation") public class ResourceValue implements IResourceValue { - private final String mType; + private final ResourceType mType; private final String mName; private String mValue = null; private final boolean mIsFramwork; - public ResourceValue(String type, String name, boolean isFramwork) { + public ResourceValue(ResourceType type, String name, boolean isFramwork) { mType = type; mName = name; mIsFramwork = isFramwork; } - public ResourceValue(String type, String name, String value, boolean isFramework) { + public ResourceValue(ResourceType type, String name, String value, boolean isFramework) { mType = type; mName = name; mValue = value; mIsFramwork = isFramework; } + public ResourceType getResourceType() { + return mType; + } + /** * Returns the type of the resource. For instance "drawable", "color", etc... + * @deprecated use {@link #getResourceType()} instead. */ public String getType() { - return mType; + return mType.getName(); } /** @@ -70,7 +76,6 @@ public class ResourceValue implements IResourceValue { return mIsFramwork; } - /** * Sets the value of the resource. * @param value the new value diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java index a9f499f..429bd26 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java @@ -18,6 +18,7 @@ package com.android.ide.common.rendering.api; import com.android.layoutlib.api.IResourceValue; import com.android.layoutlib.api.IStyleResourceValue; +import com.android.resources.ResourceType; import java.util.HashMap; @@ -30,11 +31,12 @@ public final class StyleResourceValue extends ResourceValue implements IStyleRes private String mParentStyle = null; private HashMap<String, ResourceValue> mItems = new HashMap<String, ResourceValue>(); - public StyleResourceValue(String type, String name, boolean isFramework) { + public StyleResourceValue(ResourceType type, String name, boolean isFramework) { super(type, name, isFramework); } - public StyleResourceValue(String type, String name, String parentStyle, boolean isFramework) { + public StyleResourceValue(ResourceType type, String name, String parentStyle, + boolean isFramework) { super(type, name, isFramework); mParentStyle = parentStyle; } |