Repository URL to install this package:
|
Version:
0.0.6 ▾
|
react-native-motif-sdk
/
android
/
src
/
main
/
java
/
com
/
vipera
/
de
/
rn
/
assetmanager
/
RNBundlePathResolver.java
|
|---|
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();
}
}