mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-06 22:38:37 +08:00
Add separate JSBunldeLoader for assets
Reviewed By: mhorowitz Differential Revision: D3735897 fbshipit-source-id: 990d45e9cb40a9afce1df8f8fd0b73c62e13158a
This commit is contained in:
committed by
Facebook Github Bot 8
parent
96de161304
commit
0c2fdf4b6a
@@ -220,7 +220,7 @@ public abstract class ReactInstanceManager {
|
||||
|
||||
protected final List<ReactPackage> mPackages = new ArrayList<>();
|
||||
|
||||
protected @Nullable String mJSBundleFile;
|
||||
protected @Nullable String mJSBundleAssetUrl;
|
||||
protected @Nullable JSBundleLoader mJSBundleLoader;
|
||||
protected @Nullable String mJSMainModuleName;
|
||||
protected @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
|
||||
@@ -252,7 +252,9 @@ public abstract class ReactInstanceManager {
|
||||
* Example: {@code "index.android.js"}
|
||||
*/
|
||||
public Builder setBundleAssetName(String bundleAssetName) {
|
||||
return this.setJSBundleFile(bundleAssetName == null ? null : "assets://" + bundleAssetName);
|
||||
mJSBundleAssetUrl = (bundleAssetName == null ? null : "assets://" + bundleAssetName);
|
||||
mJSBundleLoader = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,9 +263,12 @@ public abstract class ReactInstanceManager {
|
||||
* Example: {@code "assets://index.android.js" or "/sdcard/main.jsbundle"}
|
||||
*/
|
||||
public Builder setJSBundleFile(String jsBundleFile) {
|
||||
mJSBundleFile = jsBundleFile;
|
||||
mJSBundleLoader = null;
|
||||
return this;
|
||||
if (jsBundleFile.startsWith("assets://")) {
|
||||
mJSBundleAssetUrl = jsBundleFile;
|
||||
mJSBundleLoader = null;
|
||||
return this;
|
||||
}
|
||||
return setJSBundleLoader(JSBundleLoader.createFileLoader(jsBundleFile));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,7 +279,7 @@ public abstract class ReactInstanceManager {
|
||||
*/
|
||||
public Builder setJSBundleLoader(JSBundleLoader jsBundleLoader) {
|
||||
mJSBundleLoader = jsBundleLoader;
|
||||
mJSBundleFile = null;
|
||||
mJSBundleAssetUrl = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -376,11 +381,11 @@ public abstract class ReactInstanceManager {
|
||||
"Application property has not been set with this builder");
|
||||
|
||||
Assertions.assertCondition(
|
||||
mUseDeveloperSupport || mJSBundleFile != null || mJSBundleLoader != null,
|
||||
"JS Bundle File has to be provided when dev support is disabled");
|
||||
mUseDeveloperSupport || mJSBundleAssetUrl != null || mJSBundleLoader != null,
|
||||
"JS Bundle File or Asset URL has to be provided when dev support is disabled");
|
||||
|
||||
Assertions.assertCondition(
|
||||
mJSMainModuleName != null || mJSBundleFile != null || mJSBundleLoader != null,
|
||||
mJSMainModuleName != null || mJSBundleAssetUrl != null || mJSBundleLoader != null,
|
||||
"Either MainModuleName or JS Bundle File needs to be provided");
|
||||
|
||||
if (mUIImplementationProvider == null) {
|
||||
@@ -392,8 +397,8 @@ public abstract class ReactInstanceManager {
|
||||
mApplication,
|
||||
mCurrentActivity,
|
||||
mDefaultHardwareBackBtnHandler,
|
||||
(mJSBundleLoader == null && mJSBundleFile != null) ?
|
||||
JSBundleLoader.createFileLoader(mApplication, mJSBundleFile) : mJSBundleLoader,
|
||||
(mJSBundleLoader == null && mJSBundleAssetUrl != null) ?
|
||||
JSBundleLoader.createAssetLoader(mApplication, mJSBundleAssetUrl) : mJSBundleLoader,
|
||||
mJSMainModuleName,
|
||||
mPackages,
|
||||
mUseDeveloperSupport,
|
||||
|
||||
Reference in New Issue
Block a user