Skip to content

Commit

Permalink
fix: dont trigger layout config change on app resume
Browse files Browse the repository at this point in the history
  • Loading branch information
jpudysz committed Apr 5, 2024
1 parent e3ed0a2 commit baec341
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion android/src/main/java/com/unistyles/Insets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class UnistylesInsets(private val reactApplicationContext: ReactApplicationConte

// available from Android 6.0
val window = reactApplicationContext.currentActivity?.window ?: return Insets(0, 0, 0, 0)
val systemInsets = window.decorView.rootWindowInsets
val systemInsets = window.decorView.rootWindowInsets ?: return Insets(0, 0, 0, 0)

val top = (systemInsets.systemWindowInsetTop / density).roundToInt()
val bottom = (systemInsets.systemWindowInsetBottom / density).roundToInt()
Expand Down
12 changes: 7 additions & 5 deletions android/src/main/java/com/unistyles/UnistylesModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ

@Deprecated("Deprecated in Java")
override fun onCatalystInstanceDestroy() {
val activity = currentActivity ?: return

this.stopLayoutListener()
reactApplicationContext.unregisterReceiver(configurationChangeReceiver)
runnable?.let { drawHandler.removeCallbacks(it) }
reactApplicationContext.removeLifecycleEventListener(this)
this.nativeDestroy()

if (this.isCxxReady) {
this.nativeDestroy()
}
}

//endregion
Expand Down Expand Up @@ -144,7 +145,9 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ

false
} catch (e: Exception) {
false
this.isCxxReady = false

return false
}
}

Expand Down Expand Up @@ -240,7 +243,6 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
override fun onHostResume() {
if (isCxxReady) {
this.onConfigChange()
this.onLayoutConfigChange()
}

this.setupLayoutListener()
Expand Down

0 comments on commit baec341

Please sign in to comment.