use of com.android.layoutlib.bridge.MockView in project android_frameworks_base by crdroidandroid.
the class BridgeInflater method createViewFromTag.
@Override
public View createViewFromTag(View parent, String name, Context context, AttributeSet attrs, boolean ignoreThemeAttr) {
View view;
try {
view = super.createViewFromTag(parent, name, context, attrs, ignoreThemeAttr);
} catch (InflateException e) {
// Apply a theme wrapper, if allowed and one is specified.
if (!ignoreThemeAttr) {
final TypedArray ta = context.obtainStyledAttributes(attrs, ATTRS_THEME);
final int themeResId = ta.getResourceId(0, 0);
if (themeResId != 0) {
context = new ContextThemeWrapper(context, themeResId);
}
ta.recycle();
}
if (!(e.getCause() instanceof ClassNotFoundException)) {
// There is some unknown inflation exception in inflating a View that was found.
view = new MockView(context, attrs);
((MockView) view).setText(name);
Bridge.getLog().error(LayoutLog.TAG_BROKEN, e.getMessage(), e, null);
} else {
final Object lastContext = mConstructorArgs[0];
mConstructorArgs[0] = context;
// try to load the class from using the custom view loader
try {
view = loadCustomView(name, attrs);
} catch (Exception e2) {
// Wrap the real exception in an InflateException so that the calling
// method can deal with it.
InflateException exception = new InflateException();
if (!e2.getClass().equals(ClassNotFoundException.class)) {
exception.initCause(e2);
} else {
exception.initCause(e);
}
throw exception;
} finally {
mConstructorArgs[0] = lastContext;
}
}
}
setupViewInContext(view, attrs);
return view;
}
Aggregations