mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-06 09:31:11 +08:00
Adopt split segments registration approach on Android
Differential Revision: D6284863 fbshipit-source-id: 0df6b90eb0cbeab4c8a2b11f1e4dcbd5d5dfab72
This commit is contained in:
committed by
Facebook Github Bot
parent
681278947e
commit
a47431ed74
@@ -86,6 +86,9 @@ public interface CatalystInstance
|
||||
*/
|
||||
void removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener);
|
||||
|
||||
/** This method registers the file path of an additional JS segment by its ID. */
|
||||
void registerSegment(int segmentId, String path);
|
||||
|
||||
@VisibleForTesting
|
||||
void setGlobalVariable(String propName, String jsonValue);
|
||||
|
||||
|
||||
@@ -210,8 +210,9 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
jniSetSourceURL(remoteURL);
|
||||
}
|
||||
|
||||
/* package */ void setJsSegmentsDirectory(String directoryPath) {
|
||||
jniSetJsSegmentsDirectory(directoryPath);
|
||||
@Override
|
||||
public void registerSegment(int segmentId, String path) {
|
||||
jniRegisterSegment(segmentId, path);
|
||||
}
|
||||
|
||||
/* package */ void loadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously) {
|
||||
@@ -225,7 +226,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
}
|
||||
|
||||
private native void jniSetSourceURL(String sourceURL);
|
||||
private native void jniSetJsSegmentsDirectory(String directoryPath);
|
||||
private native void jniRegisterSegment(int segmentId, String path);
|
||||
private native void jniLoadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously);
|
||||
private native void jniLoadScriptFromFile(String fileName, String sourceURL, boolean loadSynchronously);
|
||||
|
||||
|
||||
@@ -96,21 +96,6 @@ public abstract class JSBundleLoader {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This loader is used to wrap other loaders and set js segments directory before executing
|
||||
* application script.
|
||||
*/
|
||||
public static JSBundleLoader createSplitBundlesLoader(
|
||||
final String jsSegmentsDirectory, final JSBundleLoader delegate) {
|
||||
return new JSBundleLoader() {
|
||||
@Override
|
||||
public String loadScript(CatalystInstanceImpl instance) {
|
||||
instance.setJsSegmentsDirectory(jsSegmentsDirectory);
|
||||
return delegate.loadScript(instance);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** Loads the script, returning the URL of the source it loaded. */
|
||||
public abstract String loadScript(CatalystInstanceImpl instance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user