From aafc912e0bea7ab08e8da42975759c56f7d4ebbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A5=A5=E6=BA=90?= Date: Thu, 20 Aug 2020 16:53:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=9C=A8MainActivity?= =?UTF-8?q?=E4=B8=AD=E4=B8=8D=E6=8F=90=E5=89=8D=E5=8A=A0=E8=BD=BDplatform.?= =?UTF-8?q?android.bundle=20=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../facebook/react/AsyncReactActivity.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/android/app/src/main/java/com/facebook/react/AsyncReactActivity.java b/android/app/src/main/java/com/facebook/react/AsyncReactActivity.java index 67736fd..717d4aa 100755 --- a/android/app/src/main/java/com/facebook/react/AsyncReactActivity.java +++ b/android/app/src/main/java/com/facebook/react/AsyncReactActivity.java @@ -1,6 +1,6 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * + *

* This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -36,7 +36,7 @@ public abstract class AsyncReactActivity extends androidx.fragment.app.FragmentActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity { - public enum ScriptType {ASSET,FILE,NETWORK} + public enum ScriptType {ASSET, FILE, NETWORK} private final ReactActivityDelegate mDelegate; protected boolean bundleLoaded = false; @@ -51,9 +51,10 @@ protected AsyncReactActivity() { * This is used to schedule rendering of the component. * e.g. "MoviesApp" */ - final private @Nullable String getMainComponentNameInner() { - if(!bundleLoaded && - getBundle().scriptType==ScriptType.NETWORK){ + final private @Nullable + String getMainComponentNameInner() { + if (!bundleLoaded && + getBundle().scriptType == ScriptType.NETWORK) { return null; } return getMainComponentName(); @@ -67,13 +68,14 @@ protected AsyncReactActivity() { * Called at construction time, override if you have a custom delegate implementation. */ protected ReactActivityDelegate createReactActivityDelegate() { - return new ReactActivityDelegate(this, getMainComponentNameInner()); + return new ReactActivityDelegate(this, null); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final ReactInstanceManager manager = ((ReactApplication)getApplication()).getReactNativeHost().getReactInstanceManager(); + mDelegate.onCreate(null); + final ReactInstanceManager manager = ((ReactApplication) getApplication()).getReactNativeHost().getReactInstanceManager(); if (!manager.hasStartedCreatingInitialContext() ||ScriptLoadUtil.getCatalystInstance(getReactNativeHost())==null) { manager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() { @@ -127,7 +129,7 @@ public void run() { ScriptLoadUtil.setJsBundleAssetPath( reactInstanceManager.getCurrentReactContext(), path); - initView(); + mDelegate.loadApp(getMainComponentName()); } } @@ -151,7 +153,6 @@ protected void loadScript(final LoadScriptListener loadListener){ ScriptLoadUtil.loadScriptFromFile(scriptPath,instance,scriptPath,false); loadListener.onLoadComplete(true,scriptPath); }else if(pathType== ScriptType.NETWORK){ - initView(); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle("Loading jsBundle"); dialogBuilder.setCancelable(false); @@ -207,10 +208,6 @@ public void run() { } } - protected void initView(){ - mDelegate.onCreate(null); - } - @Override protected void onPause() { super.onPause();