Loading tools/layoutlib/bridge/src/android/view/BridgeInflater.java +10 −7 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,8 @@ import android.util.AttributeSet; import java.io.File; import java.io.File; import static com.android.layoutlib.bridge.android.BridgeContext.getBaseContext; /** /** * Custom implementation of {@link LayoutInflater} to handle custom views. * Custom implementation of {@link LayoutInflater} to handle custom views. */ */ Loading @@ -60,8 +62,13 @@ public final class BridgeInflater extends LayoutInflater { protected BridgeInflater(LayoutInflater original, Context newContext) { protected BridgeInflater(LayoutInflater original, Context newContext) { super(original, newContext); super(original, newContext); newContext = getBaseContext(newContext); if (newContext instanceof BridgeContext) { mProjectCallback = ((BridgeContext) newContext).getProjectCallback(); } else { mProjectCallback = null; mProjectCallback = null; } } } /** /** * Instantiate a new BridgeInflater with an {@link IProjectCallback} object. * Instantiate a new BridgeInflater with an {@link IProjectCallback} object. Loading Loading @@ -154,9 +161,7 @@ public final class BridgeInflater extends LayoutInflater { @Override @Override public View inflate(int resource, ViewGroup root) { public View inflate(int resource, ViewGroup root) { Context context = getContext(); Context context = getContext(); while (context instanceof ContextThemeWrapper) { context = getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { BridgeContext bridgeContext = (BridgeContext)context; BridgeContext bridgeContext = (BridgeContext)context; Loading Loading @@ -219,9 +224,7 @@ public final class BridgeInflater extends LayoutInflater { private void setupViewInContext(View view, AttributeSet attrs) { private void setupViewInContext(View view, AttributeSet attrs) { Context context = getContext(); Context context = getContext(); while (context instanceof ContextThemeWrapper) { context = getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { BridgeContext bc = (BridgeContext) context; BridgeContext bc = (BridgeContext) context; // get the view key // get the view key Loading tools/layoutlib/bridge/src/android/view/MenuInflater_Delegate.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -48,9 +48,7 @@ public class MenuInflater_Delegate { AttributeSet attrs) { AttributeSet attrs) { if (menuItem instanceof BridgeMenuItemImpl) { if (menuItem instanceof BridgeMenuItemImpl) { Context context = thisInflater.getContext(); Context context = thisInflater.getContext(); while (context instanceof ContextThemeWrapper) { context = BridgeContext.getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { Object viewKey = BridgeInflater.getViewKeyFromParser( Object viewKey = BridgeInflater.getViewKeyFromParser( attrs, ((BridgeContext) context), null, false); attrs, ((BridgeContext) context), null, false); Loading tools/layoutlib/bridge/src/android/view/ViewGroup_Delegate.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -122,9 +122,7 @@ public class ViewGroup_Delegate { @NonNull @NonNull private static DisplayMetrics getMetrics(View view) { private static DisplayMetrics getMetrics(View view) { Context context = view.getContext(); Context context = view.getContext(); while (context instanceof ContextThemeWrapper) { context = BridgeContext.getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { return ((BridgeContext) context).getMetrics(); return ((BridgeContext) context).getMetrics(); } } Loading tools/layoutlib/bridge/src/com/android/internal/view/menu/BridgeMenuItemImpl.java +1 −4 Original line number Original line Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.internal.view.menu; import com.android.layoutlib.bridge.android.BridgeContext; import com.android.layoutlib.bridge.android.BridgeContext; import android.content.Context; import android.content.Context; import android.view.ContextThemeWrapper; import android.view.View; import android.view.View; /** /** Loading @@ -42,9 +41,7 @@ public class BridgeMenuItemImpl extends MenuItemImpl { CharSequence title, int showAsAction) { CharSequence title, int showAsAction) { super(menu, group, id, categoryOrder, ordering, title, showAsAction); super(menu, group, id, categoryOrder, ordering, title, showAsAction); Context context = menu.getContext(); Context context = menu.getContext(); while (context instanceof ContextThemeWrapper) { context = BridgeContext.getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { mContext = ((BridgeContext) context); mContext = ((BridgeContext) context); } } Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.IntentSender; import android.content.IntentSender; Loading Loading @@ -934,6 +935,13 @@ public final class BridgeContext extends Context { return defValue; return defValue; } } public static Context getBaseContext(Context context) { while (context instanceof ContextWrapper) { context = ((ContextWrapper) context).getBaseContext(); } return context; } //------------ NOT OVERRIDEN -------------------- //------------ NOT OVERRIDEN -------------------- @Override @Override Loading Loading
tools/layoutlib/bridge/src/android/view/BridgeInflater.java +10 −7 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,8 @@ import android.util.AttributeSet; import java.io.File; import java.io.File; import static com.android.layoutlib.bridge.android.BridgeContext.getBaseContext; /** /** * Custom implementation of {@link LayoutInflater} to handle custom views. * Custom implementation of {@link LayoutInflater} to handle custom views. */ */ Loading @@ -60,8 +62,13 @@ public final class BridgeInflater extends LayoutInflater { protected BridgeInflater(LayoutInflater original, Context newContext) { protected BridgeInflater(LayoutInflater original, Context newContext) { super(original, newContext); super(original, newContext); newContext = getBaseContext(newContext); if (newContext instanceof BridgeContext) { mProjectCallback = ((BridgeContext) newContext).getProjectCallback(); } else { mProjectCallback = null; mProjectCallback = null; } } } /** /** * Instantiate a new BridgeInflater with an {@link IProjectCallback} object. * Instantiate a new BridgeInflater with an {@link IProjectCallback} object. Loading Loading @@ -154,9 +161,7 @@ public final class BridgeInflater extends LayoutInflater { @Override @Override public View inflate(int resource, ViewGroup root) { public View inflate(int resource, ViewGroup root) { Context context = getContext(); Context context = getContext(); while (context instanceof ContextThemeWrapper) { context = getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { BridgeContext bridgeContext = (BridgeContext)context; BridgeContext bridgeContext = (BridgeContext)context; Loading Loading @@ -219,9 +224,7 @@ public final class BridgeInflater extends LayoutInflater { private void setupViewInContext(View view, AttributeSet attrs) { private void setupViewInContext(View view, AttributeSet attrs) { Context context = getContext(); Context context = getContext(); while (context instanceof ContextThemeWrapper) { context = getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { BridgeContext bc = (BridgeContext) context; BridgeContext bc = (BridgeContext) context; // get the view key // get the view key Loading
tools/layoutlib/bridge/src/android/view/MenuInflater_Delegate.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -48,9 +48,7 @@ public class MenuInflater_Delegate { AttributeSet attrs) { AttributeSet attrs) { if (menuItem instanceof BridgeMenuItemImpl) { if (menuItem instanceof BridgeMenuItemImpl) { Context context = thisInflater.getContext(); Context context = thisInflater.getContext(); while (context instanceof ContextThemeWrapper) { context = BridgeContext.getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { Object viewKey = BridgeInflater.getViewKeyFromParser( Object viewKey = BridgeInflater.getViewKeyFromParser( attrs, ((BridgeContext) context), null, false); attrs, ((BridgeContext) context), null, false); Loading
tools/layoutlib/bridge/src/android/view/ViewGroup_Delegate.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -122,9 +122,7 @@ public class ViewGroup_Delegate { @NonNull @NonNull private static DisplayMetrics getMetrics(View view) { private static DisplayMetrics getMetrics(View view) { Context context = view.getContext(); Context context = view.getContext(); while (context instanceof ContextThemeWrapper) { context = BridgeContext.getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { return ((BridgeContext) context).getMetrics(); return ((BridgeContext) context).getMetrics(); } } Loading
tools/layoutlib/bridge/src/com/android/internal/view/menu/BridgeMenuItemImpl.java +1 −4 Original line number Original line Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.internal.view.menu; import com.android.layoutlib.bridge.android.BridgeContext; import com.android.layoutlib.bridge.android.BridgeContext; import android.content.Context; import android.content.Context; import android.view.ContextThemeWrapper; import android.view.View; import android.view.View; /** /** Loading @@ -42,9 +41,7 @@ public class BridgeMenuItemImpl extends MenuItemImpl { CharSequence title, int showAsAction) { CharSequence title, int showAsAction) { super(menu, group, id, categoryOrder, ordering, title, showAsAction); super(menu, group, id, categoryOrder, ordering, title, showAsAction); Context context = menu.getContext(); Context context = menu.getContext(); while (context instanceof ContextThemeWrapper) { context = BridgeContext.getBaseContext(context); context = ((ContextThemeWrapper) context).getBaseContext(); } if (context instanceof BridgeContext) { if (context instanceof BridgeContext) { mContext = ((BridgeContext) context); mContext = ((BridgeContext) context); } } Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.IntentSender; import android.content.IntentSender; Loading Loading @@ -934,6 +935,13 @@ public final class BridgeContext extends Context { return defValue; return defValue; } } public static Context getBaseContext(Context context) { while (context instanceof ContextWrapper) { context = ((ContextWrapper) context).getBaseContext(); } return context; } //------------ NOT OVERRIDEN -------------------- //------------ NOT OVERRIDEN -------------------- @Override @Override Loading