diff options
4 files changed, 41 insertions, 13 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java index 1b9b103..ca6982f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java @@ -339,16 +339,17 @@ public final class ProjectCallback extends LegacyCallback { return constructor.newInstance(constructorParameters); } - public String getAdapterItemValue(ResourceReference adapterView, ResourceReference itemRef, - int fullPosition, int typePosition, ResourceReference viewRef, String viewClass) { - if (viewClass.contains("TextView")) { + public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie, + ResourceReference itemRef, int fullPosition, int typePosition, + ResourceReference viewRef, ViewAttribute viewAttribute, Object defaultValue) { + if (viewAttribute == ViewAttribute.TEXT && ((String) defaultValue).length() == 0) { return viewRef.getName() + " " + typePosition; } return null; } - public AdapterBinding getAdapterBinding(ResourceReference adapterView) { + public AdapterBinding getAdapterBinding(ResourceReference adapterView, Object adapterCookie) { return null; } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java index 5b4bf38..ec8b717 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java @@ -265,7 +265,7 @@ public class ProjectResources extends ResourceRepository { synchronized (mDynamicIds) { Integer value = mDynamicIds.get(name); if (value == null) { - value = new Integer(++mDynamicSeed); + value = Integer.valueOf(++mDynamicSeed); mDynamicIds.put(name, value); mRevDynamicIds.put(value, name); } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java index 18e7bac..9b8f554 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java @@ -129,12 +129,14 @@ public class ApiDemosRenderingTest extends SdkTestCase { return null; } - public String getAdapterItemValue(ResourceReference adapterView, ResourceReference itemRef, - int fullPosition, int typePosition, ResourceReference viewRef, String viewClass) { + public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie, + ResourceReference itemRef, int fullPosition, int typePosition, + ResourceReference viewRef, ViewAttribute viewAttribute, Object defaultValue) { return null; } - public AdapterBinding getAdapterBinding(ResourceReference adapterView) { + public AdapterBinding getAdapterBinding(ResourceReference adapterView, + Object adapterCookie) { return null; } } 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 1a16c48..144d317 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 @@ -19,6 +19,8 @@ package com.android.ide.common.rendering.api; import com.android.resources.ResourceType; import com.android.util.Pair; +import java.net.URL; + /** * Callback for project information needed by the Layout Library. * Classes implementing this interface provide methods giving access to some project data, like @@ -26,6 +28,23 @@ import com.android.util.Pair; */ public interface IProjectCallback { + public enum ViewAttribute { + TEXT(String.class), + IS_CHECKED(Boolean.class), + SRC(URL.class), + COLOR(Integer.class); + + private final Class<?> mClass; + + private ViewAttribute(Class<?> theClass) { + mClass = theClass; + } + + public Class<?> getAttributeClass() { + return mClass; + } + } + /** * Loads a custom view with the given constructor signature and arguments. * @param name The fully qualified name of the class. @@ -77,17 +96,22 @@ public interface IProjectCallback { /** * Returns the value of an item used by an adapter. * @param adapterView The {@link ResourceReference} for the adapter view info. + * @param adapterCookie the view cookie for this particular view. * @param itemRef the {@link ResourceReference} for the layout used by the adapter item. * @param fullPosition the position of the item in the full list. * @param typePosition the position of the item if only items of the same type are considered. * If there is only one type of items, this is the same as <var>position</var>. * @param viewRef The {@link ResourceReference} for the view we're trying to fill. - * @param viewClass the class name of the view we're trying to fill. + * @param ViewAttribute the attribute being queried. + * @param defaultValue the default value for this attribute. The object class matches the + * class associated with the {@link ViewAttribute}. * @return the item value or null if there's no value. + * + * @see ViewAttribute#getAttributeClass() */ - String getAdapterItemValue(ResourceReference adapterView, ResourceReference itemRef, - int fullPosition, int typePosition, - ResourceReference viewRef, String viewClass); + Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie, + ResourceReference itemRef, int fullPosition, int typePosition, + ResourceReference viewRef, ViewAttribute viewAttribute, Object defaultValue); /** * Returns an adapter binding for a given adapter view. @@ -95,7 +119,8 @@ public interface IProjectCallback { * the given {@link ResourceReference} already. * * @param adapterView the adapter view to return the adapter binding for. + * @param adapterCookie the view cookie for this particular view. * @return an adapter binding for the given view or null if there's no data. */ - AdapterBinding getAdapterBinding(ResourceReference adapterView); + AdapterBinding getAdapterBinding(ResourceReference adapterView, Object adapterCookie); } |