Skip to content

Commit 630f426

Browse files
committed
Adds support for fabric android overrides
1 parent a3774e0 commit 630f426

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
import android.os.Bundle;
44
import android.view.View;
55
import android.widget.ImageView;
6-
76
import com.facebook.react.ReactActivityDelegate;
8-
import com.facebook.react.ReactRootView;
9-
7+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
8+
import com.facebook.react.defaults.DefaultReactActivityDelegate;
109
import com.reactnativenavigation.NavigationActivity;
1110

1211
import androidx.annotation.Nullable;
1312

1413
public class MainActivity extends NavigationActivity {
1514

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

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)