@@ -29,14 +29,14 @@ import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn
2929import com.facebook.react.views.view.setStatusBarStyle
3030import com.facebook.react.views.view.setStatusBarTranslucency
3131import com.facebook.react.views.view.setStatusBarVisibility
32+ import java.util.Collections
33+ import java.util.WeakHashMap
3234
3335/* * [NativeModule] that allows changing the appearance of the status bar. */
3436@ReactModule(name = NativeStatusBarManagerAndroidSpec .NAME )
3537internal class StatusBarModule (reactContext : ReactApplicationContext ? ) :
3638 NativeStatusBarManagerAndroidSpec (reactContext), ExtraWindowEventListener {
3739
38- private val extraWindows = mutableSetOf<Window >()
39-
4040 init {
4141 reactApplicationContext.addExtraWindowEventListener(this )
4242 }
@@ -47,9 +47,9 @@ internal class StatusBarModule(reactContext: ReactApplicationContext?) :
4747 }
4848
4949 override fun onExtraWindowCreate (window : Window ) {
50- extraWindows.add(window)
51-
5250 UiThreadUtil .runOnUiThread {
51+ extraWindows.add(window)
52+
5353 reactApplicationContext.currentActivity?.window?.let {
5454 val controller = WindowCompat .getInsetsController(it, it.decorView)
5555 val insets = ViewCompat .getRootWindowInsets(it.decorView)
@@ -63,7 +63,7 @@ internal class StatusBarModule(reactContext: ReactApplicationContext?) :
6363 }
6464
6565 override fun onExtraWindowDestroy (window : Window ) {
66- extraWindows.remove(window)
66+ UiThreadUtil .runOnUiThread { extraWindows.remove(window) }
6767 }
6868
6969 @Suppress(" DEPRECATION" )
@@ -177,5 +177,6 @@ internal class StatusBarModule(reactContext: ReactApplicationContext?) :
177177 private const val HEIGHT_KEY = " HEIGHT"
178178 private const val DEFAULT_BACKGROUND_COLOR_KEY = " DEFAULT_BACKGROUND_COLOR"
179179 const val NAME : String = NativeStatusBarManagerAndroidSpec .NAME
180+ private val extraWindows = Collections .newSetFromMap<Window >(WeakHashMap ())
180181 }
181182}
0 commit comments