Search in sources :

Example 1 with AnyRes

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

the class ShadowArscAssetManager9 method nativeGetResourceIdentifier.

// static jint NativeGetResourceIdentifier(JNIEnv* env, jclass /*clazz*/, jlong ptr, jstring name,
// jstring def_type, jstring def_package) {
@Implementation(minSdk = P)
@AnyRes
protected static int nativeGetResourceIdentifier(long ptr, @NonNull String name, @Nullable String def_type, @Nullable String def_package) {
    String name_utf8 = name;
    if (name_utf8 == null) {
        // This will throw NPE.
        return 0;
    }
    String type = null;
    if (def_type != null) {
        String type_utf8 = def_type;
        CHECK(type_utf8 != null);
        type = type_utf8;
    }
    String package_ = null;
    if (def_package != null) {
        String package_utf8 = def_package;
        CHECK(package_utf8 != null);
        package_ = package_utf8;
    }
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    return (int) (assetmanager.GetResourceId(name_utf8, type, package_));
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) AnyRes(android.annotation.AnyRes) Implementation(org.robolectric.annotation.Implementation)

Example 2 with AnyRes

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

the class ShadowArscAssetManager10 method nativeGetResourceIdentifier.

// static jint NativeGetResourceIdentifier(JNIEnv* env, jclass /*clazz*/, jlong ptr, jstring name,
// jstring def_type, jstring def_package) {
@Implementation(minSdk = P)
@AnyRes
protected static int nativeGetResourceIdentifier(long ptr, @NonNull String name, @Nullable String def_type, @Nullable String def_package) {
    String name_utf8 = name;
    if (name_utf8 == null) {
        // This will throw NPE.
        return 0;
    }
    String type = null;
    if (def_type != null) {
        String type_utf8 = def_type;
        CHECK(type_utf8 != null);
        type = type_utf8;
    }
    String package_ = null;
    if (def_package != null) {
        String package_utf8 = def_package;
        CHECK(package_utf8 != null);
        package_ = package_utf8;
    }
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    return (int) (assetmanager.GetResourceId(name_utf8, type, package_));
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) AnyRes(android.annotation.AnyRes) Implementation(org.robolectric.annotation.Implementation)

Aggregations

AnyRes (android.annotation.AnyRes)2 Implementation (org.robolectric.annotation.Implementation)2 CppAssetManager2 (org.robolectric.res.android.CppAssetManager2)2