Loading tools/layoutlib/bridge/src/android/app/Fragment_Delegate.java +11 −11 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package android.app; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutlibCallback; import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.content.Context; Loading @@ -30,19 +30,19 @@ import android.os.Bundle; * * The methods being re-implemented are the ones responsible for instantiating Fragment objects. * Because the classes of these objects are found in the project, these methods need access to * {@link IProjectCallback} object. They are however static methods, so the callback is set * before the inflation through {@link #setProjectCallback(IProjectCallback)}. * {@link LayoutlibCallback} object. They are however static methods, so the callback is set * before the inflation through {@link #setLayoutlibCallback(LayoutlibCallback)}. */ public class Fragment_Delegate { private static IProjectCallback sProjectCallback; private static LayoutlibCallback sLayoutlibCallback; /** * Sets the current {@link IProjectCallback} to be used to instantiate classes coming * Sets the current {@link LayoutlibCallback} to be used to instantiate classes coming * from the project being rendered. */ public static void setProjectCallback(IProjectCallback projectCallback) { sProjectCallback = projectCallback; public static void setLayoutlibCallback(LayoutlibCallback layoutlibCallback) { sLayoutlibCallback = layoutlibCallback; } /** Loading @@ -62,17 +62,17 @@ public class Fragment_Delegate { * This is currently just used to get its ClassLoader. * @param fname The class name of the fragment to instantiate. * @param args Bundle of arguments to supply to the fragment, which it * can retrieve with {@link #getArguments()}. May be null. * can retrieve with {@link Fragment#getArguments()}. May be null. * @return Returns a new fragment instance. * @throws InstantiationException If there is a failure in instantiating * @throws Fragment.InstantiationException If there is a failure in instantiating * the given fragment class. This is a runtime exception; it is not * normally expected to happen. */ @LayoutlibDelegate /*package*/ static Fragment instantiate(Context context, String fname, Bundle args) { try { if (sProjectCallback != null) { Fragment f = (Fragment) sProjectCallback.loadView(fname, if (sLayoutlibCallback != null) { Fragment f = (Fragment) sLayoutlibCallback.loadView(fname, new Class[0], new Object[0]); if (args != null) { Loading tools/layoutlib/bridge/src/android/content/res/BridgeResources.java +12 −12 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ package android.content.res; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.LayoutlibCallback; import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; Loading Loading @@ -49,7 +49,7 @@ import java.io.InputStream; public final class BridgeResources extends Resources { private BridgeContext mContext; private IProjectCallback mProjectCallback; private LayoutlibCallback mLayoutlibCallback; private boolean[] mPlatformResourceFlag = new boolean[1]; private TypedValue mTmpValue = new TypedValue(); Loading Loading @@ -94,12 +94,12 @@ public final class BridgeResources extends Resources { AssetManager assets, DisplayMetrics metrics, Configuration config, IProjectCallback projectCallback) { LayoutlibCallback layoutlibCallback) { return Resources.mSystem = new BridgeResources(context, assets, metrics, config, projectCallback); layoutlibCallback); } /** Loading @@ -109,16 +109,16 @@ public final class BridgeResources extends Resources { public static void disposeSystem() { if (Resources.mSystem instanceof BridgeResources) { ((BridgeResources)(Resources.mSystem)).mContext = null; ((BridgeResources)(Resources.mSystem)).mProjectCallback = null; ((BridgeResources)(Resources.mSystem)).mLayoutlibCallback = null; } Resources.mSystem = null; } private BridgeResources(BridgeContext context, AssetManager assets, DisplayMetrics metrics, Configuration config, IProjectCallback projectCallback) { Configuration config, LayoutlibCallback layoutlibCallback) { super(assets, metrics, config); mContext = context; mProjectCallback = projectCallback; mLayoutlibCallback = layoutlibCallback; } public BridgeTypedArray newTypeArray(int numEntries, boolean platformFile) { Loading @@ -138,8 +138,8 @@ public final class BridgeResources extends Resources { } // didn't find a match in the framework? look in the project. if (mProjectCallback != null) { resourceInfo = mProjectCallback.resolveResourceId(id); if (mLayoutlibCallback != null) { resourceInfo = mLayoutlibCallback.resolveResourceId(id); if (resourceInfo != null) { platformResFlag_out[0] = false; Loading Loading @@ -252,7 +252,7 @@ public final class BridgeResources extends Resources { try { // check if the current parser can provide us with a custom parser. if (mPlatformResourceFlag[0] == false) { parser = mProjectCallback.getParser(value); parser = mLayoutlibCallback.getParser(value); } // create a new one manually if needed. Loading Loading @@ -687,8 +687,8 @@ public final class BridgeResources extends Resources { Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(id); // if the name is unknown in the framework, get it from the custom view loader. if (resourceInfo == null && mProjectCallback != null) { resourceInfo = mProjectCallback.resolveResourceId(id); if (resourceInfo == null && mLayoutlibCallback != null) { resourceInfo = mLayoutlibCallback.resolveResourceId(id); } String message = null; Loading tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java +2 −2 Original line number Diff line number Diff line Loading @@ -646,7 +646,7 @@ public final class BridgeTypedArray extends TypedArray { if (isFrameworkId) { idValue = Bridge.getResourceId(ResourceType.ID, idName); } else { idValue = mContext.getProjectCallback().getResourceId(ResourceType.ID, idName); idValue = mContext.getLayoutlibCallback().getResourceId(ResourceType.ID, idName); } return idValue == null ? defValue : idValue; } Loading @@ -666,7 +666,7 @@ public final class BridgeTypedArray extends TypedArray { idValue = Bridge.getResourceId(resValue.getResourceType(), resValue.getName()); } else { idValue = mContext.getProjectCallback().getResourceId( idValue = mContext.getLayoutlibCallback().getResourceId( resValue.getResourceType(), resValue.getName()); } Loading tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java +3 −3 Original line number Diff line number Diff line Loading @@ -69,8 +69,8 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes { // this is not an attribute in the android namespace, we query the customviewloader, if // the namespaces match. if (mContext.getProjectCallback().getNamespace().equals(ns)) { Integer v = mContext.getProjectCallback().getResourceId(ResourceType.ATTR, name); if (mContext.getLayoutlibCallback().getNamespace().equals(ns)) { Integer v = mContext.getLayoutlibCallback().getResourceId(ResourceType.ATTR, name); if (v != null) { return v.intValue(); } Loading Loading @@ -273,7 +273,7 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes { if (mPlatformFile || resource.isFramework()) { id = Bridge.getResourceId(resource.getResourceType(), resource.getName()); } else { id = mContext.getProjectCallback().getResourceId( id = mContext.getLayoutlibCallback().getResourceId( resource.getResourceType(), resource.getName()); } Loading tools/layoutlib/bridge/src/android/view/BridgeInflater.java +12 −11 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package android.view; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutlibCallback; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.MergeCookie; import com.android.ide.common.rendering.api.ResourceReference; Loading Loading @@ -46,7 +46,7 @@ import static com.android.layoutlib.bridge.android.BridgeContext.getBaseContext; */ public final class BridgeInflater extends LayoutInflater { private final IProjectCallback mProjectCallback; private final LayoutlibCallback mLayoutlibCallback; private boolean mIsInMerge = false; private ResourceReference mResourceReference; Loading @@ -64,21 +64,21 @@ public final class BridgeInflater extends LayoutInflater { super(original, newContext); newContext = getBaseContext(newContext); if (newContext instanceof BridgeContext) { mProjectCallback = ((BridgeContext) newContext).getProjectCallback(); mLayoutlibCallback = ((BridgeContext) newContext).getLayoutlibCallback(); } else { mProjectCallback = null; mLayoutlibCallback = null; } } /** * Instantiate a new BridgeInflater with an {@link IProjectCallback} object. * Instantiate a new BridgeInflater with an {@link LayoutlibCallback} object. * * @param context The Android application context. * @param projectCallback the {@link IProjectCallback} object. * @param layoutlibCallback the {@link LayoutlibCallback} object. */ public BridgeInflater(Context context, IProjectCallback projectCallback) { public BridgeInflater(Context context, LayoutlibCallback layoutlibCallback) { super(context); mProjectCallback = projectCallback; mLayoutlibCallback = layoutlibCallback; mConstructorArgs[0] = context; } Loading Loading @@ -167,12 +167,13 @@ public final class BridgeInflater extends LayoutInflater { ResourceValue value = null; @SuppressWarnings("deprecation") Pair<ResourceType, String> layoutInfo = Bridge.resolveResourceId(resource); if (layoutInfo != null) { value = bridgeContext.getRenderResources().getFrameworkResource( ResourceType.LAYOUT, layoutInfo.getSecond()); } else { layoutInfo = mProjectCallback.resolveResourceId(resource); layoutInfo = mLayoutlibCallback.resolveResourceId(resource); if (layoutInfo != null) { value = bridgeContext.getRenderResources().getProjectResource( Loading Loading @@ -203,7 +204,7 @@ public final class BridgeInflater extends LayoutInflater { } private View loadCustomView(String name, AttributeSet attrs) throws Exception { if (mProjectCallback != null) { if (mLayoutlibCallback != null) { // first get the classname in case it's not the node name if (name.equals("view")) { name = attrs.getAttributeValue(null, "class"); Loading @@ -211,7 +212,7 @@ public final class BridgeInflater extends LayoutInflater { mConstructorArgs[1] = attrs; Object customView = mProjectCallback.loadView(name, mConstructorSignature, Object customView = mLayoutlibCallback.loadView(name, mConstructorSignature, mConstructorArgs); if (customView instanceof View) { Loading Loading
tools/layoutlib/bridge/src/android/app/Fragment_Delegate.java +11 −11 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package android.app; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutlibCallback; import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.content.Context; Loading @@ -30,19 +30,19 @@ import android.os.Bundle; * * The methods being re-implemented are the ones responsible for instantiating Fragment objects. * Because the classes of these objects are found in the project, these methods need access to * {@link IProjectCallback} object. They are however static methods, so the callback is set * before the inflation through {@link #setProjectCallback(IProjectCallback)}. * {@link LayoutlibCallback} object. They are however static methods, so the callback is set * before the inflation through {@link #setLayoutlibCallback(LayoutlibCallback)}. */ public class Fragment_Delegate { private static IProjectCallback sProjectCallback; private static LayoutlibCallback sLayoutlibCallback; /** * Sets the current {@link IProjectCallback} to be used to instantiate classes coming * Sets the current {@link LayoutlibCallback} to be used to instantiate classes coming * from the project being rendered. */ public static void setProjectCallback(IProjectCallback projectCallback) { sProjectCallback = projectCallback; public static void setLayoutlibCallback(LayoutlibCallback layoutlibCallback) { sLayoutlibCallback = layoutlibCallback; } /** Loading @@ -62,17 +62,17 @@ public class Fragment_Delegate { * This is currently just used to get its ClassLoader. * @param fname The class name of the fragment to instantiate. * @param args Bundle of arguments to supply to the fragment, which it * can retrieve with {@link #getArguments()}. May be null. * can retrieve with {@link Fragment#getArguments()}. May be null. * @return Returns a new fragment instance. * @throws InstantiationException If there is a failure in instantiating * @throws Fragment.InstantiationException If there is a failure in instantiating * the given fragment class. This is a runtime exception; it is not * normally expected to happen. */ @LayoutlibDelegate /*package*/ static Fragment instantiate(Context context, String fname, Bundle args) { try { if (sProjectCallback != null) { Fragment f = (Fragment) sProjectCallback.loadView(fname, if (sLayoutlibCallback != null) { Fragment f = (Fragment) sLayoutlibCallback.loadView(fname, new Class[0], new Object[0]); if (args != null) { Loading
tools/layoutlib/bridge/src/android/content/res/BridgeResources.java +12 −12 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ package android.content.res; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.LayoutlibCallback; import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; Loading Loading @@ -49,7 +49,7 @@ import java.io.InputStream; public final class BridgeResources extends Resources { private BridgeContext mContext; private IProjectCallback mProjectCallback; private LayoutlibCallback mLayoutlibCallback; private boolean[] mPlatformResourceFlag = new boolean[1]; private TypedValue mTmpValue = new TypedValue(); Loading Loading @@ -94,12 +94,12 @@ public final class BridgeResources extends Resources { AssetManager assets, DisplayMetrics metrics, Configuration config, IProjectCallback projectCallback) { LayoutlibCallback layoutlibCallback) { return Resources.mSystem = new BridgeResources(context, assets, metrics, config, projectCallback); layoutlibCallback); } /** Loading @@ -109,16 +109,16 @@ public final class BridgeResources extends Resources { public static void disposeSystem() { if (Resources.mSystem instanceof BridgeResources) { ((BridgeResources)(Resources.mSystem)).mContext = null; ((BridgeResources)(Resources.mSystem)).mProjectCallback = null; ((BridgeResources)(Resources.mSystem)).mLayoutlibCallback = null; } Resources.mSystem = null; } private BridgeResources(BridgeContext context, AssetManager assets, DisplayMetrics metrics, Configuration config, IProjectCallback projectCallback) { Configuration config, LayoutlibCallback layoutlibCallback) { super(assets, metrics, config); mContext = context; mProjectCallback = projectCallback; mLayoutlibCallback = layoutlibCallback; } public BridgeTypedArray newTypeArray(int numEntries, boolean platformFile) { Loading @@ -138,8 +138,8 @@ public final class BridgeResources extends Resources { } // didn't find a match in the framework? look in the project. if (mProjectCallback != null) { resourceInfo = mProjectCallback.resolveResourceId(id); if (mLayoutlibCallback != null) { resourceInfo = mLayoutlibCallback.resolveResourceId(id); if (resourceInfo != null) { platformResFlag_out[0] = false; Loading Loading @@ -252,7 +252,7 @@ public final class BridgeResources extends Resources { try { // check if the current parser can provide us with a custom parser. if (mPlatformResourceFlag[0] == false) { parser = mProjectCallback.getParser(value); parser = mLayoutlibCallback.getParser(value); } // create a new one manually if needed. Loading Loading @@ -687,8 +687,8 @@ public final class BridgeResources extends Resources { Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(id); // if the name is unknown in the framework, get it from the custom view loader. if (resourceInfo == null && mProjectCallback != null) { resourceInfo = mProjectCallback.resolveResourceId(id); if (resourceInfo == null && mLayoutlibCallback != null) { resourceInfo = mLayoutlibCallback.resolveResourceId(id); } String message = null; Loading
tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java +2 −2 Original line number Diff line number Diff line Loading @@ -646,7 +646,7 @@ public final class BridgeTypedArray extends TypedArray { if (isFrameworkId) { idValue = Bridge.getResourceId(ResourceType.ID, idName); } else { idValue = mContext.getProjectCallback().getResourceId(ResourceType.ID, idName); idValue = mContext.getLayoutlibCallback().getResourceId(ResourceType.ID, idName); } return idValue == null ? defValue : idValue; } Loading @@ -666,7 +666,7 @@ public final class BridgeTypedArray extends TypedArray { idValue = Bridge.getResourceId(resValue.getResourceType(), resValue.getName()); } else { idValue = mContext.getProjectCallback().getResourceId( idValue = mContext.getLayoutlibCallback().getResourceId( resValue.getResourceType(), resValue.getName()); } Loading
tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java +3 −3 Original line number Diff line number Diff line Loading @@ -69,8 +69,8 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes { // this is not an attribute in the android namespace, we query the customviewloader, if // the namespaces match. if (mContext.getProjectCallback().getNamespace().equals(ns)) { Integer v = mContext.getProjectCallback().getResourceId(ResourceType.ATTR, name); if (mContext.getLayoutlibCallback().getNamespace().equals(ns)) { Integer v = mContext.getLayoutlibCallback().getResourceId(ResourceType.ATTR, name); if (v != null) { return v.intValue(); } Loading Loading @@ -273,7 +273,7 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes { if (mPlatformFile || resource.isFramework()) { id = Bridge.getResourceId(resource.getResourceType(), resource.getName()); } else { id = mContext.getProjectCallback().getResourceId( id = mContext.getLayoutlibCallback().getResourceId( resource.getResourceType(), resource.getName()); } Loading
tools/layoutlib/bridge/src/android/view/BridgeInflater.java +12 −11 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package android.view; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutlibCallback; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.MergeCookie; import com.android.ide.common.rendering.api.ResourceReference; Loading Loading @@ -46,7 +46,7 @@ import static com.android.layoutlib.bridge.android.BridgeContext.getBaseContext; */ public final class BridgeInflater extends LayoutInflater { private final IProjectCallback mProjectCallback; private final LayoutlibCallback mLayoutlibCallback; private boolean mIsInMerge = false; private ResourceReference mResourceReference; Loading @@ -64,21 +64,21 @@ public final class BridgeInflater extends LayoutInflater { super(original, newContext); newContext = getBaseContext(newContext); if (newContext instanceof BridgeContext) { mProjectCallback = ((BridgeContext) newContext).getProjectCallback(); mLayoutlibCallback = ((BridgeContext) newContext).getLayoutlibCallback(); } else { mProjectCallback = null; mLayoutlibCallback = null; } } /** * Instantiate a new BridgeInflater with an {@link IProjectCallback} object. * Instantiate a new BridgeInflater with an {@link LayoutlibCallback} object. * * @param context The Android application context. * @param projectCallback the {@link IProjectCallback} object. * @param layoutlibCallback the {@link LayoutlibCallback} object. */ public BridgeInflater(Context context, IProjectCallback projectCallback) { public BridgeInflater(Context context, LayoutlibCallback layoutlibCallback) { super(context); mProjectCallback = projectCallback; mLayoutlibCallback = layoutlibCallback; mConstructorArgs[0] = context; } Loading Loading @@ -167,12 +167,13 @@ public final class BridgeInflater extends LayoutInflater { ResourceValue value = null; @SuppressWarnings("deprecation") Pair<ResourceType, String> layoutInfo = Bridge.resolveResourceId(resource); if (layoutInfo != null) { value = bridgeContext.getRenderResources().getFrameworkResource( ResourceType.LAYOUT, layoutInfo.getSecond()); } else { layoutInfo = mProjectCallback.resolveResourceId(resource); layoutInfo = mLayoutlibCallback.resolveResourceId(resource); if (layoutInfo != null) { value = bridgeContext.getRenderResources().getProjectResource( Loading Loading @@ -203,7 +204,7 @@ public final class BridgeInflater extends LayoutInflater { } private View loadCustomView(String name, AttributeSet attrs) throws Exception { if (mProjectCallback != null) { if (mLayoutlibCallback != null) { // first get the classname in case it's not the node name if (name.equals("view")) { name = attrs.getAttributeValue(null, "class"); Loading @@ -211,7 +212,7 @@ public final class BridgeInflater extends LayoutInflater { mConstructorArgs[1] = attrs; Object customView = mProjectCallback.loadView(name, mConstructorSignature, Object customView = mLayoutlibCallback.loadView(name, mConstructorSignature, mConstructorArgs); if (customView instanceof View) { Loading