use of com.android.layoutlib.bridge.MockView in project platform_frameworks_base by android.
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;
}
use of com.android.layoutlib.bridge.MockView in project android_frameworks_base by DirtyUnicorns.
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;
}
use of com.android.layoutlib.bridge.MockView in project android_frameworks_base by AOSPA.
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;
}
use of com.android.layoutlib.bridge.MockView in project android by JetBrains.
the class ViewLoader method createMockView.
@NotNull
private MockView createMockView(@NotNull String className, @Nullable Class<?>[] constructorSignature, @Nullable Object[] constructorArgs) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, NoSuchFieldException {
MockView mockView = (MockView) createNewInstance(MockView.class, constructorSignature, constructorArgs, true);
String label = getShortClassName(className);
switch(label) {
case VIEW_FRAGMENT:
label = "<fragment>";
// when used from the layout editor
break;
case VIEW_INCLUDE:
label = "Text";
break;
}
mockView.setText(label);
mockView.setGravity(Gravity.CENTER);
return mockView;
}
use of com.android.layoutlib.bridge.MockView in project android_frameworks_base by ResurrectionRemix.
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