From a9147cd5aaa706c8fd9af20bb62ea57fe073e2fa Mon Sep 17 00:00:00 2001 From: Daniel Salinas Date: Sun, 21 Aug 2022 16:41:49 -0400 Subject: [PATCH] Expose when setNavigationRoot is called on RootPresenter --- .../java/com/reactnativenavigation/NavigationActivity.java | 4 +++- .../viewcontrollers/viewcontroller/RootPresenter.java | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java b/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java index 121b64e876a..0eccdd3d8f9 100644 --- a/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java +++ b/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java @@ -31,6 +31,7 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard private PermissionListener mPermissionListener; protected Navigator navigator; + protected RootPresenter rootPresenter; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -39,11 +40,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { return; } addDefaultSplashLayout(); + rootPresenter = new RootPresenter(); navigator = new Navigator(this, new ChildControllersRegistry(), new ModalStack(this), new OverlayManager(), - new RootPresenter() + rootPresenter ); navigator.bindViews(); getReactGateway().onActivityCreated(this); diff --git a/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/RootPresenter.java b/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/RootPresenter.java index 17c81ad2298..7f4c22ae5f3 100644 --- a/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/RootPresenter.java +++ b/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/RootPresenter.java @@ -19,6 +19,7 @@ public class RootPresenter { private final RootAnimator animator; private CoordinatorLayout rootLayout; private final LayoutDirectionApplier layoutDirectionApplier; + private boolean setRootCalled = false; public void setRootContainer(CoordinatorLayout rootLayout) { this.rootLayout = rootLayout; @@ -28,6 +29,10 @@ public RootPresenter() { this(new RootAnimator(), new LayoutDirectionApplier()); } + public boolean setRootCalled() { + return setRootCalled; + } + @VisibleForTesting public RootPresenter(RootAnimator animator, LayoutDirectionApplier layoutDirectionApplier) { this.animator = animator; @@ -35,6 +40,7 @@ public RootPresenter(RootAnimator animator, LayoutDirectionApplier layoutDirecti } public void setRoot(ViewController appearingRoot, ViewController disappearingRoot, Options defaultOptions, CommandListener listener, ReactInstanceManager reactInstanceManager) { + setRootCalled = true; layoutDirectionApplier.apply(appearingRoot, defaultOptions, reactInstanceManager); rootLayout.addView(appearingRoot.getView(), matchParentWithBehaviour(new BehaviourDelegate(appearingRoot))); Options options = appearingRoot.resolveCurrentOptions(defaultOptions);