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 −17 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 @@ -153,11 +153,6 @@ public final class BridgeResources extends Resources { return null; } @Override public Drawable getDrawable(int id) throws NotFoundException { return getDrawable(id, null); } @Override public Drawable getDrawable(int id, Theme theme) { Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag); Loading Loading @@ -257,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 @@ -692,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 +33 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.content.res; import com.android.annotations.Nullable; import com.android.ide.common.rendering.api.AttrResourceValue; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.RenderResources; Loading @@ -40,9 +41,12 @@ import android.view.LayoutInflater_Delegate; import android.view.ViewGroup.LayoutParams; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import static com.android.ide.common.rendering.api.RenderResources.*; /** * Custom implementation of TypedArray to handle non compiled resources. */ Loading @@ -56,6 +60,11 @@ public final class BridgeTypedArray extends TypedArray { private final String[] mNames; private final boolean[] mIsFramework; // Contains ids that are @empty. We still store null in mResourceData for that index, since we // want to save on the check against empty, each time a resource value is requested. @Nullable private int[] mEmptyIds; public BridgeTypedArray(BridgeResources resources, BridgeContext context, int len, boolean platformFile) { super(resources, null, null, 0); Loading Loading @@ -90,19 +99,32 @@ public final class BridgeTypedArray extends TypedArray { // fills TypedArray.mIndices which is used to implement getIndexCount/getIndexAt // first count the array size int count = 0; ArrayList<Integer> emptyIds = null; for (int i = 0; i < mResourceData.length; i++) { ResourceValue data = mResourceData[i]; if (data != null) { if (RenderResources.REFERENCE_NULL.equals(data.getValue())) { // No need to store this resource value. This saves needless checking for // "@null" every time an attribute is requested. String dataValue = data.getValue(); if (REFERENCE_NULL.equals(dataValue) || REFERENCE_UNDEFINED.equals(dataValue)) { mResourceData[i] = null; } else if (REFERENCE_EMPTY.equals(dataValue)) { mResourceData[i] = null; if (emptyIds == null) { emptyIds = new ArrayList<Integer>(4); } emptyIds.add(i); } else { count++; } } } if (emptyIds != null) { mEmptyIds = new int[emptyIds.size()]; for (int i = 0; i < emptyIds.size(); i++) { mEmptyIds[i] = emptyIds.get(i); } } // allocate the table with an extra to store the size mIndices = new int[count+1]; mIndices[0] = count; Loading Loading @@ -624,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 @@ -644,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 Loading @@ -748,6 +770,12 @@ public final class BridgeTypedArray extends TypedArray { return index >= 0 && index < mResourceData.length && mResourceData[index] != null; } @Override public boolean hasValueOrEmpty(int index) { return hasValue(index) || index >= 0 && index < mResourceData.length && mEmptyIds != null && Arrays.binarySearch(mEmptyIds, index) >= 0; } /** * Retrieve the raw TypedValue for the attribute at <var>index</var> * and return a temporary object holding its data. This object is only 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 −17 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 @@ -153,11 +153,6 @@ public final class BridgeResources extends Resources { return null; } @Override public Drawable getDrawable(int id) throws NotFoundException { return getDrawable(id, null); } @Override public Drawable getDrawable(int id, Theme theme) { Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag); Loading Loading @@ -257,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 @@ -692,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 +33 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.content.res; import com.android.annotations.Nullable; import com.android.ide.common.rendering.api.AttrResourceValue; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.RenderResources; Loading @@ -40,9 +41,12 @@ import android.view.LayoutInflater_Delegate; import android.view.ViewGroup.LayoutParams; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import static com.android.ide.common.rendering.api.RenderResources.*; /** * Custom implementation of TypedArray to handle non compiled resources. */ Loading @@ -56,6 +60,11 @@ public final class BridgeTypedArray extends TypedArray { private final String[] mNames; private final boolean[] mIsFramework; // Contains ids that are @empty. We still store null in mResourceData for that index, since we // want to save on the check against empty, each time a resource value is requested. @Nullable private int[] mEmptyIds; public BridgeTypedArray(BridgeResources resources, BridgeContext context, int len, boolean platformFile) { super(resources, null, null, 0); Loading Loading @@ -90,19 +99,32 @@ public final class BridgeTypedArray extends TypedArray { // fills TypedArray.mIndices which is used to implement getIndexCount/getIndexAt // first count the array size int count = 0; ArrayList<Integer> emptyIds = null; for (int i = 0; i < mResourceData.length; i++) { ResourceValue data = mResourceData[i]; if (data != null) { if (RenderResources.REFERENCE_NULL.equals(data.getValue())) { // No need to store this resource value. This saves needless checking for // "@null" every time an attribute is requested. String dataValue = data.getValue(); if (REFERENCE_NULL.equals(dataValue) || REFERENCE_UNDEFINED.equals(dataValue)) { mResourceData[i] = null; } else if (REFERENCE_EMPTY.equals(dataValue)) { mResourceData[i] = null; if (emptyIds == null) { emptyIds = new ArrayList<Integer>(4); } emptyIds.add(i); } else { count++; } } } if (emptyIds != null) { mEmptyIds = new int[emptyIds.size()]; for (int i = 0; i < emptyIds.size(); i++) { mEmptyIds[i] = emptyIds.get(i); } } // allocate the table with an extra to store the size mIndices = new int[count+1]; mIndices[0] = count; Loading Loading @@ -624,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 @@ -644,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 Loading @@ -748,6 +770,12 @@ public final class BridgeTypedArray extends TypedArray { return index >= 0 && index < mResourceData.length && mResourceData[index] != null; } @Override public boolean hasValueOrEmpty(int index) { return hasValue(index) || index >= 0 && index < mResourceData.length && mEmptyIds != null && Arrays.binarySearch(mEmptyIds, index) >= 0; } /** * Retrieve the raw TypedValue for the attribute at <var>index</var> * and return a temporary object holding its data. This object is only 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