From: Xavier Ducrohet Date: Mon, 6 Jun 2011 22:29:32 +0000 (-0700) Subject: Add a new getParser method to IProjectCallback. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3301da3ae01b2a756178265403fb33b512a166dd;p=android-x86%2Fsdk.git Add a new getParser method to IProjectCallback. This is used to make the implementation easier with access to the XML file path in the ResourceValue. Change-Id: Iedbb194bdf4b3d17841be1d50c384b62615bae8f --- 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 a20cc6cf0..c3698fde6 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 @@ -31,6 +31,7 @@ import com.android.ide.common.rendering.api.ILayoutPullParser; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.ResourceReference; +import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.rendering.api.Result; import com.android.ide.common.rendering.legacy.LegacyCallback; import com.android.ide.eclipse.adt.AdtConstants; @@ -402,6 +403,10 @@ public final class ProjectCallback extends LegacyCallback { return null; } + public ILayoutPullParser getParser(ResourceValue layoutResource) { + return getParser(layoutResource.getName()); + } + public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie, ResourceReference itemRef, int fullPosition, int typePosition, int fullChildPosition, int typeChildPosition, diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java index d5a182906..026907e20 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java @@ -32,7 +32,7 @@ import java.util.Map; */ public abstract class Bridge { - public final static int API_CURRENT = 6; + public final static int API_CURRENT = 7; /** * Returns the API level of the layout library. 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 b91b59828..d35ca353c 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 @@ -97,10 +97,20 @@ public interface IProjectCallback { * Returns a custom parser for the layout of the given name. * @param layoutName the name of the layout. * @return returns a custom parser or null if no custom parsers are needed. + * @deprecated This is replaced by {@link #getParser(ResourceValue)} but older version + * of the layoutlib (before API7) will still call this method. */ + @Deprecated ILayoutPullParser getParser(String layoutName); /** + * Returns a custom parser for a given layout. + * @param layoutResource The layout. + * @return returns a custom parser or null if no custom parsers are needed. + */ + ILayoutPullParser getParser(ResourceValue layoutResource); + + /** * 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.