use of org.robolectric.res.android.ResXMLTree in project robolectric by robolectric.
the class ShadowXmlBlock method nativeCreate.
@Implementation
protected static Number nativeCreate(byte[] bArray, int off, int len) {
if (bArray == null) {
throw new NullPointerException();
}
int bLen = bArray.length;
if (off < 0 || off >= bLen || len < 0 || len > bLen || (off + len) > bLen) {
throw new IndexOutOfBoundsException();
}
// todo: optimize
byte[] b = new byte[len];
System.arraycopy(bArray, off, b, 0, len);
ResXMLTree osb = new ResXMLTree(null);
osb.setTo(b, len, true);
if (osb.getError() != NO_ERROR) {
throw new IllegalArgumentException();
}
return RuntimeEnvironment.castNativePtr(Registries.NATIVE_RES_XML_TREES.register(osb));
}
use of org.robolectric.res.android.ResXMLTree in project robolectric by robolectric.
the class ShadowXmlBlock method nativeCreateParseState.
@Implementation(minSdk = VERSION_CODES.LOLLIPOP, maxSdk = VERSION_CODES.P)
protected static long nativeCreateParseState(long obj) {
ResXMLTree osb = Registries.NATIVE_RES_XML_TREES.getNativeObject(obj);
// if (osb == NULL) {
// jniThrowNullPointerException(env, NULL);
// return 0;
// }
ResXMLParser st = new ResXMLParser(osb);
// if (st == NULL) {
// jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
// return 0;
// }
st.restart();
return Registries.NATIVE_RES_XML_PARSERS.register(st);
}
Aggregations