Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
react-native-motif-sdk / android / src / main / java / com / vipera / de / rn / assetmanager / RNBundlePathResolver.java
Size: Mime:
package com.vipera.de.rn.assetmanager;

import android.content.Context;

import java.io.File;

public class RNBundlePathResolver {
    public static String resolvePath(Context appContext, RNAssetBundleInfo bundleInfo){
        String bundleAssetName = bundleInfo.getBundleName();
        if(bundleInfo.getType() == RNAssetBundleInfo.Type.EMBEDDED){
             return bundleAssetName == null ? null : ( "assets://" + bundleAssetName);
        }
        return resolveDeployedPath(appContext,bundleInfo);
    }

    public static String resolveDeployedPath(Context context, RNAssetBundleInfo bundleInfo) {
        File dir  = new File(context.getFilesDir(),bundleInfo.getDeployFolder());
        if(!dir.exists() || !dir.isDirectory()) {
            throw new IllegalStateException("Resolved bundle dir path not exists or is a file");
        }
        File bundleFile = new File(dir,bundleInfo.getBundleName());
        if(!bundleFile.exists() || !bundleFile.isFile()){
            throw new IllegalStateException("Resolved bundle file not exists or is a directory");
        }
        return bundleFile.getAbsolutePath();
    }
}