From 6fd87387e5f866e00f3edfed98247070177bca8c Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Wed, 30 Oct 2024 14:45:18 +0100 Subject: [PATCH] fix some buttons didn't work after when the activity was re-created --- .../streetcomplete/screens/main/MainActivity.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainActivity.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainActivity.kt index 66c402e55d..2ebb0e276a 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainActivity.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainActivity.kt @@ -176,7 +176,8 @@ class MainActivity : private var wasFollowingPosition: Boolean? = null private var wasNavigationMode: Boolean? = null - private var mapFragment: MainMapFragment? = null + private val mapFragment: MainMapFragment? get() = + supportFragmentManager.findFragmentById(R.id.mapFragment) as MainMapFragment? private val bottomSheetFragment: Fragment? get() = supportFragmentManager.findFragmentByTag(BOTTOM_SHEET) @@ -215,12 +216,6 @@ class MainActivity : locationManager = FineLocationManager(this, this::onLocationChanged) - supportFragmentManager.addFragmentOnAttachListener { _, fragment -> - when (fragment) { - is MainMapFragment -> mapFragment = fragment - } - } - binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root)