refactor(app): 重构 MultipleReactActivityDelegate 并更新相关逻辑- 将 MultipleReactActivityDelegate从 runtime 包移动到 multiple包
- 更新 BuzActivity 中的条件判断,使用 BuildConfig.DEBUG 替代 BuildConfig.BUILD_TYPE - 移除 gradle.properties 中的 configuration-cache 设置
这个提交包含在:
父节点
397b2ed843
当前提交
d1458981c5
@ -1,13 +1,13 @@
|
||||
package com.trust.ywx
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import com.facebook.react.ReactActivity
|
||||
import com.trust.ywx.specs.navigation.NavigationHelper
|
||||
import com.facebook.react.ReactActivityDelegate
|
||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
||||
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
||||
import com.facebook.react.runtime.MultipleReactActivityDelegate
|
||||
import android.widget.Toast
|
||||
import com.trust.ywx.multiple.MultipleReactActivityDelegate
|
||||
import com.trust.ywx.specs.navigation.NavigationHelper
|
||||
|
||||
class BuzActivity : ReactActivity() {
|
||||
|
||||
@ -22,7 +22,7 @@ class BuzActivity : ReactActivity() {
|
||||
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
||||
*/
|
||||
override fun createReactActivityDelegate(): ReactActivityDelegate =
|
||||
if (BuildConfig.BUILD_TYPE == "debug") DefaultReactActivityDelegate(
|
||||
if (BuildConfig.DEBUG) DefaultReactActivityDelegate(
|
||||
this,
|
||||
mainComponentName,
|
||||
fabricEnabled
|
||||
@ -31,7 +31,7 @@ class BuzActivity : ReactActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
AppManager.addActivity(this)
|
||||
Toast.makeText(this, "BuzActivity:"+BuildConfig.BUILD_TYPE, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, "BuzActivity:" + BuildConfig.DEBUG, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.facebook.react.runtime
|
||||
package com.trust.ywx.multiple
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
@ -17,6 +17,8 @@ import com.facebook.react.bridge.ReactContext
|
||||
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture
|
||||
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.enableBridgelessArchitecture
|
||||
import com.facebook.react.runtime.ReactHostHelper
|
||||
import com.facebook.react.runtime.ReactHostImpl
|
||||
|
||||
class MultipleReactActivityDelegate(
|
||||
activity: ReactActivity,
|
||||
@ -48,7 +50,11 @@ class MultipleReactActivityDelegate(
|
||||
reactHost?.start()?.waitForCompletion()
|
||||
val result =
|
||||
helper.loadBundle(
|
||||
JSBundleLoader.createAssetLoader(this.reactActivity, "assets://index.android.bundle", false),
|
||||
JSBundleLoader.createAssetLoader(
|
||||
this.reactActivity,
|
||||
"assets://index.android.bundle",
|
||||
false
|
||||
),
|
||||
)
|
||||
|
||||
Log.i("TestApp", "load biz bundle ==> $result")
|
||||
@ -63,7 +69,8 @@ class MultipleReactActivityDelegate(
|
||||
this.isFabricEnabled,
|
||||
) {
|
||||
override fun createRootView(): ReactRootView {
|
||||
var rootView: ReactRootView? = this@MultipleReactActivityDelegate.createRootView()
|
||||
var rootView: ReactRootView? =
|
||||
this@MultipleReactActivityDelegate.createRootView()
|
||||
if (rootView == null) {
|
||||
rootView = super.createRootView()
|
||||
}
|
||||
@ -77,8 +84,13 @@ class MultipleReactActivityDelegate(
|
||||
override fun onReactContextInitialized(context: ReactContext) {
|
||||
Log.i("TestApp", "Multiple onReactContextInitialized")
|
||||
|
||||
val instance = reactNativeHost.reactInstanceManager.currentReactContext?.catalystInstance
|
||||
instance?.loadScriptFromAssets(context.assets, "assets://index.android.bundle", false)
|
||||
val instance =
|
||||
reactNativeHost.reactInstanceManager.currentReactContext?.catalystInstance
|
||||
instance?.loadScriptFromAssets(
|
||||
context.assets,
|
||||
"assets://index.android.bundle",
|
||||
false
|
||||
)
|
||||
Log.i("TestApp", "loaded biz bundle")
|
||||
if (mainComponentName != null) {
|
||||
try {
|
||||
@ -100,7 +112,8 @@ class MultipleReactActivityDelegate(
|
||||
override fun getReactDelegate(): ReactDelegate = mReactDelegate!!
|
||||
|
||||
@DeprecatedInNewArchitecture(message = "Use getReactHost()")
|
||||
override fun getReactInstanceManager(): ReactInstanceManager = mReactDelegate!!.reactInstanceManager
|
||||
override fun getReactInstanceManager(): ReactInstanceManager =
|
||||
mReactDelegate!!.reactInstanceManager
|
||||
|
||||
override fun loadApp(appKey: String?) {
|
||||
mReactDelegate!!.loadApp(appKey)
|
||||
@ -37,4 +37,4 @@ newArchEnabled=true
|
||||
# Use this property to enable or disable the Hermes JS engine.
|
||||
# If set to false, you will be using JSC instead.
|
||||
hermesEnabled=true
|
||||
org.gradle.configuration-cache=true
|
||||
#org.gradle.configuration-cache=true
|
||||
正在加载...
在新工单中引用
屏蔽一个用户