Search in sources :

Example 1 with String8

use of org.robolectric.res.android.String8 in project robolectric by robolectric.

the class ShadowArscAssetManager method list.

@Implementation
protected final String[] list(String path) throws IOException {
    CppAssetManager am = assetManagerForJavaObject();
    String fileName8 = path;
    if (fileName8 == null) {
        return null;
    }
    AssetDir dir = am.openDir(fileName8);
    if (dir == null) {
        throw new FileNotFoundException(fileName8);
    }
    int N = dir.getFileCount();
    String[] array = new String[dir.getFileCount()];
    for (int i = 0; i < N; i++) {
        String8 name = dir.getFileName(i);
        array[i] = name.string();
    }
    return array;
}
Also used : CppAssetManager(org.robolectric.res.android.CppAssetManager) AssetDir(org.robolectric.res.android.AssetDir) FileNotFoundException(java.io.FileNotFoundException) String8(org.robolectric.res.android.String8) Implementation(org.robolectric.annotation.Implementation)

Example 2 with String8

use of org.robolectric.res.android.String8 in project robolectric by robolectric.

the class ShadowArscAssetManager method addAssetPathNative.

@HiddenApi
@Implementation(minSdk = VERSION_CODES.N)
protected int addAssetPathNative(String path, boolean appAsLib) {
    if (Strings.isNullOrEmpty(path)) {
        return 0;
    }
    CppAssetManager am = assetManagerForJavaObject();
    if (am == null) {
        return 0;
    }
    final Ref<Integer> cookie = new Ref<>(null);
    boolean res = am.addAssetPath(new String8(path), cookie, appAsLib);
    return (res) ? cookie.get() : 0;
}
Also used : Ref(org.robolectric.res.android.Ref) CppAssetManager(org.robolectric.res.android.CppAssetManager) String8(org.robolectric.res.android.String8) HiddenApi(org.robolectric.annotation.HiddenApi) Implementation(org.robolectric.annotation.Implementation)

Aggregations

Implementation (org.robolectric.annotation.Implementation)2 CppAssetManager (org.robolectric.res.android.CppAssetManager)2 String8 (org.robolectric.res.android.String8)2 FileNotFoundException (java.io.FileNotFoundException)1 HiddenApi (org.robolectric.annotation.HiddenApi)1 AssetDir (org.robolectric.res.android.AssetDir)1 Ref (org.robolectric.res.android.Ref)1