Skip to content

Commit b3b11a9

Browse files
committed
Adds support for fabric android overrides
1 parent 1623d6d commit b3b11a9

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed
Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
package com.reactnativenavigation.playground;
22

33
import android.os.Bundle;
4-
import android.view.View;
54
import android.widget.ImageView;
6-
75
import com.facebook.react.ReactActivityDelegate;
8-
import com.facebook.react.ReactRootView;
9-
6+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
7+
import com.facebook.react.defaults.DefaultReactActivityDelegate;
108
import com.reactnativenavigation.NavigationActivity;
119

1210
import androidx.annotation.Nullable;
1311

1412
public class MainActivity extends NavigationActivity {
1513

14+
@Override
15+
protected String getMainComponentName() {
16+
return "PlaygroundApp";
17+
}
18+
1619
@Override
1720
protected void onCreate(@Nullable Bundle savedInstanceState) {
1821
super.onCreate(savedInstanceState);
@@ -24,4 +27,21 @@ private void setSplashLayout() {
2427
img.setImageDrawable(getDrawable(R.drawable.ic_android));
2528
setContentView(img);
2629
}
30+
31+
/**
32+
* Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
33+
* DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
34+
* (aka React 18) with two boolean flags.
35+
*/
36+
@Override
37+
protected ReactActivityDelegate createReactActivityDelegate() {
38+
return new DefaultReactActivityDelegate(
39+
this,
40+
getMainComponentName(),
41+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
42+
DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
43+
// If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
44+
DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
45+
);
46+
}
2747
}

playground/android/app/src/main/java/com/reactnativenavigation/playground/MainApplication.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.facebook.react.PackageList;
44
import com.facebook.react.ReactNativeHost;
55
import com.facebook.react.ReactPackage;
6+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
67
import com.reactnativenavigation.NavigationApplication;
78
import com.reactnativenavigation.react.NavigationPackage;
89
import com.reactnativenavigation.react.NavigationReactNativeHost;
@@ -30,6 +31,15 @@ public List<ReactPackage> getPackages() {
3031
packages.add(new NavigationPackage(mReactNativeHost));
3132
return packages;
3233
}
34+
35+
@Override
36+
protected boolean isNewArchEnabled() {
37+
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
38+
}
39+
@Override
40+
protected Boolean isHermesEnabled() {
41+
return BuildConfig.IS_HERMES_ENABLED;
42+
}
3343
};
3444
private final ReactNativeHost mNewArchitectureNativeHost =
3545
new MainApplicationReactNativeHost(this);
@@ -38,6 +48,11 @@ public List<ReactPackage> getPackages() {
3848
public void onCreate() {
3949
super.onCreate();
4050
registerExternalComponent("RNNCustomComponent", new FragmentCreator());
51+
52+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
53+
// If you opted-in for the New Architecture, we load the native entry point for this app.
54+
DefaultNewArchitectureEntryPoint.load();
55+
}
4156
}
4257

4358
@Override

0 commit comments

Comments
 (0)