diff options
author | Xavier Ducrohet <xav@android.com> | 2010-11-10 16:18:58 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-11-11 12:15:58 -0800 |
commit | f29be828de51dbe2f55508cd620142e35cd19cbd (patch) | |
tree | 0a0a6ec8b2ad6c4f09614f2a32ecf591d8f1d335 /layoutlib_api | |
parent | 6c88ff3409763cac0d757bbcdf8f09d2bb5fda9e (diff) | |
download | sdk-f29be828de51dbe2f55508cd620142e35cd19cbd.zip sdk-f29be828de51dbe2f55508cd620142e35cd19cbd.tar.gz sdk-f29be828de51dbe2f55508cd620142e35cd19cbd.tar.bz2 |
Make ADT use the new layoutlib API.
ADT now exclusively use the new API.
The older platforms that still use the old API are
accessed through a compatibility layer provided by the class
LayoutBridgeWrapper that converts the old to the new API (both
input and output).
The wrapper and the loading code for the bridge have moved
to layoutlib_utils, but into the ide.common package.
Layoutlib_utils is to be renamed ide-common later.
.sdk.LoadStatus has moved into .ide.common too since
it's used by the bridge loading code. As we'll move
more code into ide-common it's ok to have it there anyway.
Also did some minor fix to the API:
- missing implementation of ViewInfo
- Made a singleton for SUCCESS state of SceneResult.
Change-Id: I5e7130ca03b92ad71dc9c293b2ffc40566df645c
Diffstat (limited to 'layoutlib_api')
-rw-r--r-- | layoutlib_api/src/com/android/layoutlib/api/SceneResult.java | 8 | ||||
-rw-r--r-- | layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java | 19 |
2 files changed, 10 insertions, 17 deletions
diff --git a/layoutlib_api/src/com/android/layoutlib/api/SceneResult.java b/layoutlib_api/src/com/android/layoutlib/api/SceneResult.java index 7214b3f..386eecc 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/SceneResult.java +++ b/layoutlib_api/src/com/android/layoutlib/api/SceneResult.java @@ -29,13 +29,9 @@ public class SceneResult { public enum LayoutStatus { SUCCESS, ERROR, NOT_IMPLEMENTED }; /** - * Creates a successful {@link SceneResult} object. + * Singleton SUCCESS {@link SceneResult} object. */ - public SceneResult() { - mStatus = LayoutStatus.SUCCESS; - mErrorMessage = null; - mThrowable = null; - } + public static final SceneResult SUCCESS = new SceneResult(LayoutStatus.SUCCESS); /** * Creates an error {@link SceneResult} object with the given message. diff --git a/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java b/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java index 3e7d907..d991cc8 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java +++ b/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java @@ -16,7 +16,6 @@ package com.android.layoutlib.api; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -32,7 +31,7 @@ public class ViewInfo { protected final int mRight; protected final int mTop; protected final int mBottom; - protected List<ViewInfo> mChildren;; + protected List<ViewInfo> mChildren = Collections.emptyList(); public ViewInfo(String name, Object key, int left, int top, int right, int bottom) { mName = name; @@ -47,9 +46,7 @@ public class ViewInfo { * Sets the list of children {@link ViewInfo}. */ public void setChildren(List<ViewInfo> children) { - mChildren = new ArrayList<ViewInfo>(); - mChildren.addAll(children); - mChildren = Collections.unmodifiableList(mChildren); + mChildren = Collections.unmodifiableList(children); } /** @@ -65,42 +62,42 @@ public class ViewInfo { * @see IXmlPullParser#getViewKey() */ public Object getViewKey() { - return null; + return mKey; } /** * Returns the class name of the view object. Can be null. */ public String getClassName() { - return null; + return mName; } /** * Returns the left of the view bounds, relative to the view parent bounds. */ public int getLeft() { - return 0; + return mLeft; } /** * Returns the top of the view bounds, relative to the view parent bounds. */ public int getTop() { - return 0; + return mTop; } /** * Returns the right of the view bounds, relative to the view parent bounds. */ public int getRight() { - return 0; + return mRight; } /** * Returns the bottom of the view bounds, relative to the view parent bounds. */ public int getBottom() { - return 0; + return mBottom; } /** |