diff --git a/android/src/com/unciv/app/AndroidGame.kt b/android/src/com/unciv/app/AndroidGame.kt index 689419968b..bccaa3d617 100644 --- a/android/src/com/unciv/app/AndroidGame.kt +++ b/android/src/com/unciv/app/AndroidGame.kt @@ -1,5 +1,6 @@ package com.unciv.app +import android.app.Activity import android.content.Intent import android.graphics.Rect import android.net.Uri @@ -14,7 +15,9 @@ import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.basescreen.UncivStage import com.unciv.utils.concurrency.Concurrency -class AndroidGame : UncivGame() { +class AndroidGame(private val activity: Activity) : UncivGame() { + + private var lastOrientation = activity.resources.configuration.orientation fun addScreenObscuredListener() { val contentView = (Gdx.graphics as AndroidGraphics).view @@ -53,6 +56,12 @@ class AndroidGame : UncivGame() { lastFrame = currentFrame lastVisibleStage = visibleStage + val currentOrientation = activity.resources.configuration.orientation + if (lastOrientation != currentOrientation) { + lastOrientation = currentOrientation + return + } + Concurrency.runOnGLThread { EventBus.send(UncivStage.VisibleAreaChanged(visibleStage)) } diff --git a/android/src/com/unciv/app/AndroidLauncher.kt b/android/src/com/unciv/app/AndroidLauncher.kt index a5762341ee..e0c61d5b0b 100644 --- a/android/src/com/unciv/app/AndroidLauncher.kt +++ b/android/src/com/unciv/app/AndroidLauncher.kt @@ -44,7 +44,7 @@ open class AndroidLauncher : AndroidApplication() { Display.setOrientation(settings.displayOrientation) Display.setCutout(settings.androidCutout) - game = AndroidGame() + game = AndroidGame(this) initialize(game, config) game!!.setDeepLinkedGame(intent)