Search in sources :

Example 1 with AttrRes

use of android.annotation.AttrRes in project robolectric by robolectric.

the class ShadowArscAssetManager9 method nativeGetStyleAttributes.

// static jintArray NativeGetStyleAttributes(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint resid)
// {
@Implementation(minSdk = P)
@Nullable
@AttrRes
protected static int[] nativeGetStyleAttributes(long ptr, @StyleRes int resid) {
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    ResolvedBag bag = assetmanager.GetBag(resid);
    if (bag == null) {
        return null;
    }
    int[] array = new int[bag.entry_count];
    for (int i = 0; i < bag.entry_count; i++) {
        int attr_resid = bag.entries[i].key;
        // env.SetIntArrayRegion(array, i, 1, &attr_resid);
        array[i] = attr_resid;
    }
    return array;
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) ResolvedBag(org.robolectric.res.android.CppAssetManager2.ResolvedBag) AttrRes(android.annotation.AttrRes) Implementation(org.robolectric.annotation.Implementation) Nullable(android.annotation.Nullable)

Example 2 with AttrRes

use of android.annotation.AttrRes in project robolectric by robolectric.

the class ShadowArscAssetManager10 method nativeGetStyleAttributes.

// static jintArray NativeGetStyleAttributes(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint resid)
// {
@Implementation(minSdk = P)
@Nullable
@AttrRes
protected static int[] nativeGetStyleAttributes(long ptr, @StyleRes int resid) {
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    ResolvedBag bag = assetmanager.GetBag(resid);
    if (bag == null) {
        return null;
    }
    int[] array = new int[bag.entry_count];
    for (int i = 0; i < bag.entry_count; i++) {
        int attr_resid = bag.entries[i].key;
        // env.SetIntArrayRegion(array, i, 1, &attr_resid);
        array[i] = attr_resid;
    }
    return array;
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) ResolvedBag(org.robolectric.res.android.CppAssetManager2.ResolvedBag) AttrRes(android.annotation.AttrRes) Implementation(org.robolectric.annotation.Implementation) Nullable(android.annotation.Nullable)

Aggregations

AttrRes (android.annotation.AttrRes)2 Nullable (android.annotation.Nullable)2 Implementation (org.robolectric.annotation.Implementation)2 CppAssetManager2 (org.robolectric.res.android.CppAssetManager2)2 ResolvedBag (org.robolectric.res.android.CppAssetManager2.ResolvedBag)2