Methods Summary |
---|
protected java.lang.Class | findClass(java.lang.String name)
Class<?> aClass = mClasses.get(name);
if (aClass != null) {
return aClass;
}
String pathName = PROJECT_CLASSES_LOCATION.concat(name.replace('.", '/")).concat(".class");
InputStream classInputStream = getClass().getResourceAsStream(pathName);
if (classInputStream == null) {
throw new ClassNotFoundException("Unable to find class " + name + " at " + pathName);
}
byte[] data;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
data = new byte[16384];
while ((nRead = classInputStream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
data = buffer.toByteArray();
} catch (IOException e) {
// Wrap the exception with ClassNotFoundException so that caller can deal with it.
throw new ClassNotFoundException("Unable to load class " + name, e);
}
aClass = defineClass(name, data, 0, data.length);
mClasses.put(name, aClass);
return aClass;
|
public com.android.ide.common.rendering.api.ActionBarCallback | getActionBarCallback()
return mActionBarCallback;
|
public com.android.ide.common.rendering.api.AdapterBinding | getAdapterBinding(com.android.ide.common.rendering.api.ResourceReference adapterViewRef, java.lang.Object adapterCookie, java.lang.Object viewObject)
return null;
|
public java.lang.Object | getAdapterItemValue(com.android.ide.common.rendering.api.ResourceReference adapterView, java.lang.Object adapterCookie, com.android.ide.common.rendering.api.ResourceReference itemRef, int fullPosition, int positionPerType, int fullParentPosition, int parentPositionPerType, com.android.ide.common.rendering.api.ResourceReference viewRef, ViewAttribute viewAttribute, java.lang.Object defaultValue)
return null;
|
public java.lang.String | getNamespace()
return String.format(SdkConstants.NS_CUSTOM_RESOURCES_S,
PACKAGE_NAME);
|
public com.android.ide.common.rendering.api.ILayoutPullParser | getParser(com.android.ide.common.rendering.api.ResourceValue layoutResource)
return new LayoutPullParser(new File(layoutResource.getValue()));
|
public com.android.ide.common.rendering.api.ILayoutPullParser | getParser(java.lang.String layoutName)
org.junit.Assert.fail("This method shouldn't be called by this version of LayoutLib.");
return null;
|
public java.lang.Integer | getResourceId(com.android.resources.ResourceType type, java.lang.String name)
return mResources.get(type).get(name);
|
public void | initResources()
Class<?> rClass = loadClass(PACKAGE_NAME + ".R");
Class<?>[] nestedClasses = rClass.getDeclaredClasses();
for (Class<?> resClass : nestedClasses) {
final ResourceType resType = ResourceType.getEnum(resClass.getSimpleName());
if (resType != null) {
final Map<String, Integer> resName2Id = Maps.newHashMap();
mResources.put(resType, resName2Id);
for (Field field : resClass.getDeclaredFields()) {
final int modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers)) { // May not be final in library projects
final Class<?> type = field.getType();
try {
if (type.isArray() && type.getComponentType() == int.class) {
mStyleableValueToNameMap.put(
new IntArrayWrapper((int[]) field.get(null)),
field.getName());
} else if (type == int.class) {
final Integer value = (Integer) field.get(null);
mProjectResources.put(value, Pair.of(resType, field.getName()));
resName2Id.put(field.getName(), value);
} else {
mLog.error(null, "Unknown field type in R class: %1$s", type);
}
} catch (IllegalAccessException ignored) {
mLog.error(ignored, "Malformed R class: %1$s", PACKAGE_NAME + ".R");
}
}
}
}
}
|
public java.lang.Object | loadView(java.lang.String name, java.lang.Class[] constructorSignature, java.lang.Object[] constructorArgs)
Class<?> viewClass = findClass(name);
Constructor<?> viewConstructor = viewClass.getConstructor(constructorSignature);
viewConstructor.setAccessible(true);
return viewConstructor.newInstance(constructorArgs);
|
public com.android.util.Pair | resolveResourceId(int id)
return mProjectResources.get(id);
|
public java.lang.String | resolveResourceId(int[] id)
return mStyleableValueToNameMap.get(new IntArrayWrapper(id));
|