diff options
author | Xavier Ducrohet <xav@android.com> | 2011-01-28 15:18:32 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-01-28 16:45:05 -0800 |
commit | 1f72cb7cb032538b79e79d6fc7ff3905e9766ce1 (patch) | |
tree | 65cc57954e239cd9cd3c9e302b4e6ad574667a78 /ide_common | |
parent | 2e97908089f76b4c270f018cbd2e1762511df183 (diff) | |
download | sdk-1f72cb7cb032538b79e79d6fc7ff3905e9766ce1.zip sdk-1f72cb7cb032538b79e79d6fc7ff3905e9766ce1.tar.gz sdk-1f72cb7cb032538b79e79d6fc7ff3905e9766ce1.tar.bz2 |
Move Pair and annoatations into resources.jar now renamed as common.jar
Move all the resource query methods that returned an array of 2 Strings
to return a pair of ResourceType and String.
Change-Id: I6b8447aa27005de786e2defef81ad88a72363523
Diffstat (limited to 'ide_common')
-rw-r--r-- | ide_common/.classpath | 2 | ||||
-rw-r--r-- | ide_common/Android.mk | 2 | ||||
-rw-r--r-- | ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java | 4 | ||||
-rw-r--r-- | ide_common/src/com/android/ide/common/rendering/legacy/LegacyCallback.java (renamed from ide_common/src/com/android/ide/common/rendering/legacy/ILegacyCallback.java) | 25 |
4 files changed, 27 insertions, 6 deletions
diff --git a/ide_common/.classpath b/ide_common/.classpath index 9d91c20..89ce2dd 100644 --- a/ide_common/.classpath +++ b/ide_common/.classpath @@ -4,6 +4,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/> <classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_SRC/dalvik/libcore/xml/src/main/java"/> - <classpathentry combineaccessrules="false" kind="src" path="/resources"/> + <classpathentry combineaccessrules="false" kind="src" path="/common"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/ide_common/Android.mk b/ide_common/Android.mk index 2cb3f84..5316703 100644 --- a/ide_common/Android.mk +++ b/ide_common/Android.mk @@ -20,7 +20,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under,src) LOCAL_JAVA_LIBRARIES := \ layoutlib_api \ - resources \ + common \ kxml2-2.3.0 LOCAL_MODULE := ide_common 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 6fe7f10..e7ea32e 100644 --- a/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java +++ b/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java @@ -28,7 +28,7 @@ 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; import com.android.ide.common.rendering.api.Result.Status; -import com.android.ide.common.rendering.legacy.ILegacyCallback; +import com.android.ide.common.rendering.legacy.LegacyCallback; import com.android.ide.common.rendering.legacy.ILegacyPullParser; import com.android.ide.common.resources.ResourceResolver; import com.android.ide.common.sdk.LoadStatus; @@ -65,7 +65,7 @@ import java.util.Map.Entry; * For client wanting to access both new and old (pre API level 5) layout libraries, it is * important that the following interfaces be used:<br> * {@link ILegacyPullParser} instead of {@link ILayoutPullParser}<br> - * {@link ILegacyCallback} instead of{@link com.android.ide.common.rendering.api.IProjectCallback}. + * {@link LegacyCallback} instead of{@link com.android.ide.common.rendering.api.IProjectCallback}. * <p/> * These interfaces will ensure that both new and older Layout libraries can be accessed. */ diff --git a/ide_common/src/com/android/ide/common/rendering/legacy/ILegacyCallback.java b/ide_common/src/com/android/ide/common/rendering/legacy/LegacyCallback.java index 000c7c5..f4bc15a 100644 --- a/ide_common/src/com/android/ide/common/rendering/legacy/ILegacyCallback.java +++ b/ide_common/src/com/android/ide/common/rendering/legacy/LegacyCallback.java @@ -17,15 +17,36 @@ package com.android.ide.common.rendering.legacy; import com.android.ide.common.rendering.api.IProjectCallback; +import com.android.resources.ResourceType; +import com.android.util.Pair; /** - * Intermediary interface extending both old and new project call back from the layout lib API. + * Intermediary class implementing parts of both the old and new project call back from the + * layout lib API. * * Clients should use this instead of {@link IProjectCallback} to target both old and new * Layout Libraries. * */ @SuppressWarnings("deprecation") -public interface ILegacyCallback extends com.android.ide.common.rendering.api.IProjectCallback, +public abstract class LegacyCallback implements + com.android.ide.common.rendering.api.IProjectCallback, com.android.layoutlib.api.IProjectCallback { + + // ------ implementation of the old interface using the new interface. + + public final Integer getResourceValue(String type, String name) { + return getResourceId(ResourceType.getEnum(type), name); + } + + public final String[] resolveResourceValue(int id) { + Pair<ResourceType, String> info = resolveResourceId(id); + return new String[] { info.getSecond(), info.getFirst().getName() }; + } + + public final String resolveResourceValue(int[] id) { + return resolveResourceId(id); + } + + // ------ } |