Skip to content

Commit 5f118b4

Browse files
committed
Throw if rootview is null before adding animation
1 parent 091256c commit 5f118b4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.Android.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,13 @@ public override AView OnCreateView(LayoutInflater inflater, ViewGroup? container
305305

306306
_navigationRootManager = modalContext.GetNavigationRootManager();
307307
_navigationRootManager.Connect(_modal, modalContext);
308-
308+
309309
UpdateBackgroundColor();
310-
if (IsAnimated && _navigationRootManager is not null && _navigationRootManager.RootView is not null)
310+
311+
var rootView = _navigationRootManager?.RootView ??
312+
throw new InvalidOperationException("Root view not initialized");
313+
314+
if (IsAnimated)
311315
{
312316
_ = new GenericGlobalLayoutListener((listner,view) =>
313317
{
@@ -320,8 +324,7 @@ public override AView OnCreateView(LayoutInflater inflater, ViewGroup? container
320324
}
321325
},_navigationRootManager.RootView);
322326
}
323-
return _navigationRootManager?.RootView ??
324-
throw new InvalidOperationException("Root view not initialized");
327+
return rootView;
325328
}
326329
void OnAnimationEnded(object? sender, AAnimation.AnimationEndEventArgs e)
327330
{

0 commit comments

Comments
 (0)