commit 7e95b85dd53a3fd86f70aa61475e89d3ad6e0237 Author: Fabio Mazza Date: Sun Nov 23 18:32:09 2025 +0100 Move some methods in GeneralMapLibreFragment, call mapLibre onDestroy before diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt b/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt index 4270bbf..c8a2c91 100644 --- a/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt +++ b/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt @@ -67,6 +67,7 @@ abstract class GeneralMapLibreFragment: ScreenBaseFragment(), OnMapReadyCallback } override fun onResume() { + mapView.onResume() super.onResume() val newMapStyle = PreferencesHolder.getMapLibreStyleFile(requireContext()) Log.d(DEBUG_TAG, "onResume newMapStyle: $newMapStyle, lastMapStyle: $lastMapStyle") @@ -77,8 +78,19 @@ abstract class GeneralMapLibreFragment: ScreenBaseFragment(), OnMapReadyCallback @Deprecated("Deprecated in Java") override fun onLowMemory() { - super.onLowMemory() mapView.onLowMemory() + super.onLowMemory() + } + + override fun onStart() { + super.onStart() + mapView.onStart() + } + + override fun onDestroy() { + mapView.onDestroy() + Log.d(DEBUG_TAG, "Destroyed mapView Fragment!!") + super.onDestroy() } diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/LinesDetailFragment.kt b/app/src/main/java/it/reyboz/bustorino/fragments/LinesDetailFragment.kt index 2b792f5..cfe9627 100644 --- a/app/src/main/java/it/reyboz/bustorino/fragments/LinesDetailFragment.kt +++ b/app/src/main/java/it/reyboz/bustorino/fragments/LinesDetailFragment.kt @@ -1456,7 +1456,6 @@ class LinesDetailFragment() : GeneralMapLibreFragment() { override fun onResume() { super.onResume() Log.d(DEBUG_TAG, "Resetting paused from onResume") - mapView.onResume() pausedFragment = false val keySourcePositions = getString(R.string.pref_positions_source) @@ -1505,16 +1504,6 @@ class LinesDetailFragment() : GeneralMapLibreFragment() { } - override fun onStart() { - super.onStart() - mapView.onStart() - } - - override fun onDestroy() { - super.onDestroy() - mapView.onDestroy() - } - override fun onStop() { super.onStop() mapView.onStop() diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/MapLibreFragment.kt b/app/src/main/java/it/reyboz/bustorino/fragments/MapLibreFragment.kt index a74ca6c..d502eec 100644 --- a/app/src/main/java/it/reyboz/bustorino/fragments/MapLibreFragment.kt +++ b/app/src/main/java/it/reyboz/bustorino/fragments/MapLibreFragment.kt @@ -616,8 +616,6 @@ class MapLibreFragment : GeneralMapLibreFragment() { override fun onStart() { super.onStart() - mapView.onStart() - //restore state from viewModel stopsViewModel.savedState?.let { restoreMapStateFromBundle(it) @@ -628,7 +626,7 @@ class MapLibreFragment : GeneralMapLibreFragment() { override fun onResume() { super.onResume() - mapView.onResume() + //mapView.onResume() handled in GeneralMapLibreFragment //val keySourcePositions = getString(R.string.pref_positions_source) if(showBusLayer) { @@ -686,12 +684,6 @@ class MapLibreFragment : GeneralMapLibreFragment() { } - override fun onDestroy() { - super.onDestroy() - mapView.onDestroy() - Log.d(DEBUG_TAG, "Destroyed map Fragment!!") - } - override fun onMapDestroy() { mapStyle.removeLayer(STOPS_LAYER_ID) mapStyle.removeSource(STOPS_SOURCE_ID) @@ -700,7 +692,7 @@ class MapLibreFragment : GeneralMapLibreFragment() { mapStyle.removeSource(BUSES_SOURCE_ID) - map?.locationComponent?.isLocationComponentEnabled = false + //map?.locationComponent?.isLocationComponentEnabled = false } override fun getBaseViewForSnackBar(): View? { return mapView