Search in sources :

Example 1 with ResourceName

use of org.robolectric.res.android.CppAssetManager2.ResourceName in project robolectric by robolectric.

the class ShadowArscAssetManager9 method nativeGetResourceEntryName.

// static jstring NativeGetResourceEntryName(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint resid)
// {
@Implementation(minSdk = P)
@Nullable
protected static String nativeGetResourceEntryName(long ptr, @AnyRes int resid) {
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    final ResourceName name = new ResourceName();
    if (!assetmanager.GetResourceName(resid, name)) {
        return null;
    }
    if (name.entry != null) {
        return name.entry;
    // } else if (name.entry16 != null) {
    // return name.entry16; // env.NewString(reinterpret_cast<jchar*>(name.entry16),
    // name.entry_len);
    }
    return null;
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) ResourceName(org.robolectric.res.android.CppAssetManager2.ResourceName) Implementation(org.robolectric.annotation.Implementation) Nullable(android.annotation.Nullable)

Example 2 with ResourceName

use of org.robolectric.res.android.CppAssetManager2.ResourceName in project robolectric by robolectric.

the class ShadowArscAssetManager9 method nativeGetResourceName.

// static jstring NativeGetResourceName(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint resid) {
@Implementation(minSdk = P)
@Nullable
protected static String nativeGetResourceName(long ptr, @AnyRes int resid) {
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    CppAssetManager2.ResourceName name = new ResourceName();
    if (!assetmanager.GetResourceName(resid, name)) {
        return null;
    }
    StringBuilder result = new StringBuilder();
    if (name.package_ != null) {
        result.append(name.package_);
    }
    if (name.type != null) /*|| name.type16 != null*/
    {
        if (!(result.length() == 0)) {
            result.append(":");
        }
        // if (name.type != null) {
        result.append(name.type);
    // } else {
    // result.append( /*util.Utf16ToUtf8(StringPiece16(*/ name.type16 /*, name.type_len))*/);
    // }
    }
    if (name.entry != null) /*|| name.entry16 != null*/
    {
        if (!(result.length() == 0)) {
            result.append("/");
        }
        // if (name.entry != null) {
        result.append(name.entry);
    // } else {
    // result.append( /*util.Utf16ToUtf8(StringPiece16(*/ name.entry16 /*, name.entry_len)*/);
    // }
    }
    return result.toString();
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) ResourceName(org.robolectric.res.android.CppAssetManager2.ResourceName) ResourceName(org.robolectric.res.android.CppAssetManager2.ResourceName) Implementation(org.robolectric.annotation.Implementation) Nullable(android.annotation.Nullable)

Example 3 with ResourceName

use of org.robolectric.res.android.CppAssetManager2.ResourceName in project robolectric by robolectric.

the class ShadowArscAssetManager10 method nativeGetResourceTypeName.

// static jstring NativeGetResourceTypeName(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint resid)
// {
@Implementation(minSdk = P)
@Nullable
protected static String nativeGetResourceTypeName(long ptr, @AnyRes int resid) {
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    final ResourceName name = new ResourceName();
    if (!assetmanager.GetResourceName(resid, name)) {
        return null;
    }
    if (name.type != null) {
        return name.type;
    // } else if (name.get().type16 != null) {
    // return name.get().type16; // env.NewString(reinterpret_cast<jchar*>(name.type16),
    // name.type_len);
    }
    return null;
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) ResourceName(org.robolectric.res.android.CppAssetManager2.ResourceName) Implementation(org.robolectric.annotation.Implementation) Nullable(android.annotation.Nullable)

Example 4 with ResourceName

use of org.robolectric.res.android.CppAssetManager2.ResourceName in project robolectric by robolectric.

the class ShadowArscAssetManager10 method nativeGetResourceName.

// static jstring NativeGetResourceName(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint resid) {
@Implementation(minSdk = P)
@Nullable
protected static String nativeGetResourceName(long ptr, @AnyRes int resid) {
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    CppAssetManager2.ResourceName name = new ResourceName();
    if (!assetmanager.GetResourceName(resid, name)) {
        return null;
    }
    StringBuilder result = new StringBuilder();
    if (name.package_ != null) {
        result.append(name.package_);
    }
    if (name.type != null) /*|| name.type16 != null*/
    {
        if (!(result.length() == 0)) {
            result.append(":");
        }
        // if (name.type != null) {
        result.append(name.type);
    // } else {
    // result.append( /*util.Utf16ToUtf8(StringPiece16(*/ name.type16 /*, name.type_len))*/);
    // }
    }
    if (name.entry != null) /*|| name.entry16 != null*/
    {
        if (!(result.length() == 0)) {
            result.append("/");
        }
        // if (name.entry != null) {
        result.append(name.entry);
    // } else {
    // result.append( /*util.Utf16ToUtf8(StringPiece16(*/ name.entry16 /*, name.entry_len)*/);
    // }
    }
    return result.toString();
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) ResourceName(org.robolectric.res.android.CppAssetManager2.ResourceName) ResourceName(org.robolectric.res.android.CppAssetManager2.ResourceName) Implementation(org.robolectric.annotation.Implementation) Nullable(android.annotation.Nullable)

Example 5 with ResourceName

use of org.robolectric.res.android.CppAssetManager2.ResourceName in project robolectric by robolectric.

the class ShadowArscAssetManager10 method nativeGetResourceEntryName.

// static jstring NativeGetResourceEntryName(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint resid)
// {
@Implementation(minSdk = P)
@Nullable
protected static String nativeGetResourceEntryName(long ptr, @AnyRes int resid) {
    CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
    final ResourceName name = new ResourceName();
    if (!assetmanager.GetResourceName(resid, name)) {
        return null;
    }
    if (name.entry != null) {
        return name.entry;
    // } else if (name.entry16 != null) {
    // return name.entry16; // env.NewString(reinterpret_cast<jchar*>(name.entry16),
    // name.entry_len);
    }
    return null;
}
Also used : CppAssetManager2(org.robolectric.res.android.CppAssetManager2) ResourceName(org.robolectric.res.android.CppAssetManager2.ResourceName) Implementation(org.robolectric.annotation.Implementation) Nullable(android.annotation.Nullable)

Aggregations

Nullable (android.annotation.Nullable)8 Implementation (org.robolectric.annotation.Implementation)8 CppAssetManager2 (org.robolectric.res.android.CppAssetManager2)8 ResourceName (org.robolectric.res.android.CppAssetManager2.ResourceName)8 ResolvedBag (org.robolectric.res.android.CppAssetManager2.ResolvedBag)2 Entry (org.robolectric.res.android.CppAssetManager2.ResolvedBag.Entry)2 Res_value (org.robolectric.res.android.ResourceTypes.Res_value)2