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
|
package com.trust.ywx
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.widget.Toast
|
||||||
import com.facebook.react.ReactActivity
|
import com.facebook.react.ReactActivity
|
||||||
import com.trust.ywx.specs.navigation.NavigationHelper
|
|
||||||
import com.facebook.react.ReactActivityDelegate
|
import com.facebook.react.ReactActivityDelegate
|
||||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
||||||
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
||||||
import com.facebook.react.runtime.MultipleReactActivityDelegate
|
import com.trust.ywx.multiple.MultipleReactActivityDelegate
|
||||||
import android.widget.Toast
|
import com.trust.ywx.specs.navigation.NavigationHelper
|
||||||
|
|
||||||
class BuzActivity : ReactActivity() {
|
class BuzActivity : ReactActivity() {
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class BuzActivity : ReactActivity() {
|
|||||||
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
||||||
*/
|
*/
|
||||||
override fun createReactActivityDelegate(): ReactActivityDelegate =
|
override fun createReactActivityDelegate(): ReactActivityDelegate =
|
||||||
if (BuildConfig.BUILD_TYPE == "debug") DefaultReactActivityDelegate(
|
if (BuildConfig.DEBUG) DefaultReactActivityDelegate(
|
||||||
this,
|
this,
|
||||||
mainComponentName,
|
mainComponentName,
|
||||||
fabricEnabled
|
fabricEnabled
|
||||||
@ -31,7 +31,7 @@ class BuzActivity : ReactActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
AppManager.addActivity(this)
|
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() {
|
override fun onDestroy() {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package com.facebook.react.runtime
|
package com.trust.ywx.multiple
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.ActivityInfo
|
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.common.annotations.DeprecatedInNewArchitecture
|
||||||
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
||||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.enableBridgelessArchitecture
|
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.enableBridgelessArchitecture
|
||||||
|
import com.facebook.react.runtime.ReactHostHelper
|
||||||
|
import com.facebook.react.runtime.ReactHostImpl
|
||||||
|
|
||||||
class MultipleReactActivityDelegate(
|
class MultipleReactActivityDelegate(
|
||||||
activity: ReactActivity,
|
activity: ReactActivity,
|
||||||
@ -48,7 +50,11 @@ class MultipleReactActivityDelegate(
|
|||||||
reactHost?.start()?.waitForCompletion()
|
reactHost?.start()?.waitForCompletion()
|
||||||
val result =
|
val result =
|
||||||
helper.loadBundle(
|
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")
|
Log.i("TestApp", "load biz bundle ==> $result")
|
||||||
@ -63,7 +69,8 @@ class MultipleReactActivityDelegate(
|
|||||||
this.isFabricEnabled,
|
this.isFabricEnabled,
|
||||||
) {
|
) {
|
||||||
override fun createRootView(): ReactRootView {
|
override fun createRootView(): ReactRootView {
|
||||||
var rootView: ReactRootView? = this@MultipleReactActivityDelegate.createRootView()
|
var rootView: ReactRootView? =
|
||||||
|
this@MultipleReactActivityDelegate.createRootView()
|
||||||
if (rootView == null) {
|
if (rootView == null) {
|
||||||
rootView = super.createRootView()
|
rootView = super.createRootView()
|
||||||
}
|
}
|
||||||
@ -77,8 +84,13 @@ class MultipleReactActivityDelegate(
|
|||||||
override fun onReactContextInitialized(context: ReactContext) {
|
override fun onReactContextInitialized(context: ReactContext) {
|
||||||
Log.i("TestApp", "Multiple onReactContextInitialized")
|
Log.i("TestApp", "Multiple onReactContextInitialized")
|
||||||
|
|
||||||
val instance = reactNativeHost.reactInstanceManager.currentReactContext?.catalystInstance
|
val instance =
|
||||||
instance?.loadScriptFromAssets(context.assets, "assets://index.android.bundle", false)
|
reactNativeHost.reactInstanceManager.currentReactContext?.catalystInstance
|
||||||
|
instance?.loadScriptFromAssets(
|
||||||
|
context.assets,
|
||||||
|
"assets://index.android.bundle",
|
||||||
|
false
|
||||||
|
)
|
||||||
Log.i("TestApp", "loaded biz bundle")
|
Log.i("TestApp", "loaded biz bundle")
|
||||||
if (mainComponentName != null) {
|
if (mainComponentName != null) {
|
||||||
try {
|
try {
|
||||||
@ -100,7 +112,8 @@ class MultipleReactActivityDelegate(
|
|||||||
override fun getReactDelegate(): ReactDelegate = mReactDelegate!!
|
override fun getReactDelegate(): ReactDelegate = mReactDelegate!!
|
||||||
|
|
||||||
@DeprecatedInNewArchitecture(message = "Use getReactHost()")
|
@DeprecatedInNewArchitecture(message = "Use getReactHost()")
|
||||||
override fun getReactInstanceManager(): ReactInstanceManager = mReactDelegate!!.reactInstanceManager
|
override fun getReactInstanceManager(): ReactInstanceManager =
|
||||||
|
mReactDelegate!!.reactInstanceManager
|
||||||
|
|
||||||
override fun loadApp(appKey: String?) {
|
override fun loadApp(appKey: String?) {
|
||||||
mReactDelegate!!.loadApp(appKey)
|
mReactDelegate!!.loadApp(appKey)
|
||||||
@ -37,4 +37,4 @@ newArchEnabled=true
|
|||||||
# Use this property to enable or disable the Hermes JS engine.
|
# Use this property to enable or disable the Hermes JS engine.
|
||||||
# If set to false, you will be using JSC instead.
|
# If set to false, you will be using JSC instead.
|
||||||
hermesEnabled=true
|
hermesEnabled=true
|
||||||
org.gradle.configuration-cache=true
|
#org.gradle.configuration-cache=true
|
||||||
正在加载...
在新工单中引用
屏蔽一个用户