Search in sources :

Example 6 with ResXMLTree

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));
}
Also used : ResXMLTree(org.robolectric.res.android.ResXMLTree) Implementation(org.robolectric.annotation.Implementation)

Example 7 with ResXMLTree

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);
}
Also used : ResXMLTree(org.robolectric.res.android.ResXMLTree) ResXMLParser(org.robolectric.res.android.ResXMLParser) Implementation(org.robolectric.annotation.Implementation)

Aggregations

Implementation (org.robolectric.annotation.Implementation)7 ResXMLTree (org.robolectric.res.android.ResXMLTree)7 FileNotFoundException (java.io.FileNotFoundException)4 Asset (org.robolectric.res.android.Asset)4 DynamicRefTable (org.robolectric.res.android.DynamicRefTable)3 Ref (org.robolectric.res.android.Ref)3 ApkAssetsCookie (org.robolectric.res.android.ApkAssetsCookie)2 CppAssetManager2 (org.robolectric.res.android.CppAssetManager2)2 ResXMLParser (org.robolectric.res.android.ResXMLParser)2 HiddenApi (org.robolectric.annotation.HiddenApi)1 CppApkAssets (org.robolectric.res.android.CppApkAssets)1 CppAssetManager (org.robolectric.res.android.CppAssetManager)1