diff options
author | Xavier Ducrohet <xav@android.com> | 2010-11-11 18:17:37 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-11-11 20:37:13 -0800 |
commit | 71f1ce4538caa9f7d0824c7f2090d95a6c6b7d71 (patch) | |
tree | e31205d3d23fe8817a920e9609102dbe66e050ba /layoutlib_api/src | |
parent | eaba36a626658068c94addcdfb1c8f88007e3009 (diff) | |
download | sdk-71f1ce4538caa9f7d0824c7f2090d95a6c6b7d71.zip sdk-71f1ce4538caa9f7d0824c7f2090d95a6c6b7d71.tar.gz sdk-71f1ce4538caa9f7d0824c7f2090d95a6c6b7d71.tar.bz2 |
Update ViewInfo in the layoutlib API.
- support for View and LayoutParams
- support for default property value map.
Change-Id: I70028710b1f76329a8bd501428fbd68a14fafa1e
Diffstat (limited to 'layoutlib_api/src')
-rw-r--r-- | layoutlib_api/src/com/android/layoutlib/api/LayoutScene.java | 12 | ||||
-rw-r--r-- | layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java | 56 |
2 files changed, 47 insertions, 21 deletions
diff --git a/layoutlib_api/src/com/android/layoutlib/api/LayoutScene.java b/layoutlib_api/src/com/android/layoutlib/api/LayoutScene.java index 8e0fe73..85c7365 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/LayoutScene.java +++ b/layoutlib_api/src/com/android/layoutlib/api/LayoutScene.java @@ -19,6 +19,7 @@ package com.android.layoutlib.api; import com.android.layoutlib.api.SceneResult.LayoutStatus; import java.awt.image.BufferedImage; +import java.util.Map; /** * An object allowing interaction with an Android layout. @@ -81,6 +82,17 @@ public class LayoutScene { return null; } + + /** + * Returns a map of (XML attribute name, attribute value) containing only default attribute + * values, for the given view Object. + * @param viewObject the view object. + * @return a map of the default property values or null. + */ + public Map<String, String> getDefaultViewPropertyValues(Object viewObject) { + return null; + } + /** * Re-renders the layout as-is. * In case of success, this should be followed by calls to {@link #getRootView()} and diff --git a/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java b/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java index d991cc8..57be46f 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java +++ b/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java @@ -18,35 +18,48 @@ package com.android.layoutlib.api; import java.util.Collections; import java.util.List; -import java.util.Map; /** * Layout information for a specific view object */ -public class ViewInfo { +public final class ViewInfo { - protected final Object mKey; - protected final String mName; - protected final int mLeft; - protected final int mRight; - protected final int mTop; - protected final int mBottom; - protected List<ViewInfo> mChildren = Collections.emptyList(); + private final Object mCookie; + private final String mName; + private final int mLeft; + private final int mRight; + private final int mTop; + private final int mBottom; + private List<ViewInfo> mChildren = Collections.emptyList(); + private final Object mViewObject; + private final Object mLayoutParamsObject; - public ViewInfo(String name, Object key, int left, int top, int right, int bottom) { + public ViewInfo(String name, Object cookie, int left, int top, int right, int bottom) { + this(name, cookie, left, top, right, bottom, null /*viewObject*/, + null /*layoutParamsObject*/); + } + + public ViewInfo(String name, Object cookie, int left, int top, int right, int bottom, + Object viewObject, Object layoutParamsObject) { mName = name; - mKey = key; + mCookie = cookie; mLeft = left; mRight = right; mTop = top; mBottom = bottom; + mViewObject = viewObject; + mLayoutParamsObject = layoutParamsObject; } /** * Sets the list of children {@link ViewInfo}. */ public void setChildren(List<ViewInfo> children) { - mChildren = Collections.unmodifiableList(children); + if (children != null) { + mChildren = Collections.unmodifiableList(children); + } else { + mChildren = Collections.emptyList(); + } } /** @@ -57,12 +70,12 @@ public class ViewInfo { } /** - * Returns the key associated with the node. Can be null. + * Returns the cookie associated with the XML node. Can be null. * * @see IXmlPullParser#getViewKey() */ - public Object getViewKey() { - return mKey; + public Object getCookie() { + return mCookie; } /** @@ -101,11 +114,12 @@ public class ViewInfo { } /** - * Returns a map of default values for some properties. The map key is the property name, - * as found in the XML. + * Returns the actual android.view.View (or child class) object. This can be used + * to query the object properties that are not in the XML and not in the map returned + * by {@link #getDefaultPropertyValues()}. */ - public Map<String, String> getDefaultPropertyValues() { - return null; + public Object getViewObject() { + return mViewObject; } /** @@ -113,7 +127,7 @@ public class ViewInfo { * to query the object properties that are not in the XML and not in the map returned * by {@link #getDefaultPropertyValues()}. */ - public Object getViewObject() { - return null; + public Object getLayoutParamsObject() { + return mLayoutParamsObject; } } |