diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java index e43f6a2ff..88d6d3da9 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java @@ -113,6 +113,7 @@ public interface NavigationListener { private Executor mUIThreadExecutor; private ArrayList mNavigationListeners; private TrackingProtectionStore mTrackingDelegate; + private boolean mIsWindowAttached; public NavigationBarWidget(Context aContext) { super(aContext); @@ -138,6 +139,8 @@ private void initialize(@NonNull Context aContext) { updateUI(); + mIsWindowAttached = false; + mAppContext = aContext.getApplicationContext(); mUIThreadExecutor = ((VRBrowserApplication)aContext.getApplicationContext()).getExecutors().mainThread(); @@ -489,6 +492,8 @@ public void detachFromWindow() { mViewModel.getUrl().removeObserver(mUrlObserver); mViewModel = null; } + + mIsWindowAttached = false; } @Override @@ -524,6 +529,8 @@ public void attachToWindow(@NonNull WindowWidget aWindow) { setUpSession(getSession()); } handleWindowResize(); + + mIsWindowAttached = true; } private Session getSession() { @@ -798,6 +805,10 @@ private void closeFloatingMenus() { // Content delegate private Observer mIsFullscreenObserver = isFullScreen -> { + if (!mIsWindowAttached) { + return; + } + if (isFullScreen.get()) { enterFullScreenMode();