Skip to content

Commit

Permalink
Create the fullscreen observer after the listeners array initialization
Browse files Browse the repository at this point in the history
The commit 406a611 cause a crash due to the WindowWidget's mListeners
attribute was not initialized the fist time the onIsFullscreeen
callback.

We were creating an observer for the isFullScreen MutalbleLive field
and the onIsFullscreen is the callback of such observer. When the
observer is created, the callback is called with the current value
of the MutableLive object. We were creating the observer before the
mListeners field was initialized.

This PR fixes the crash by moving the observer creation after
completely the mListeners initialization.
  • Loading branch information
javifernandez committed Feb 28, 2025
1 parent 406a611 commit 2bd3874
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ private void initialize(Context aContext) {
// re-center the front window when its height changes
mViewModel.getHeight().observe((VRBrowserActivity) getContext(), observableInt -> centerFrontWindowIfNeeded());

mViewModel.getIsFullscreen().observe((VRBrowserActivity) getContext(), observableBoolean -> onIsFullscreenChanged(observableBoolean.get()));

mUIThreadExecutor = ((VRBrowserApplication)getContext().getApplicationContext()).getExecutors().mainThread();

mListeners = new CopyOnWriteArrayList<>();
setupListeners(mSession);

mViewModel.getIsFullscreen().observe((VRBrowserActivity) getContext(), observableBoolean -> onIsFullscreenChanged(observableBoolean.get()));

mLibrary = new LibraryPanel(aContext);
mLibrary.setController(this::showPanel);

Expand Down

0 comments on commit 2bd3874

Please sign in to comment.