Fix native crash (need more testing).

This commit is contained in:
Onuray Sahin 2022-01-24 16:07:11 +03:00
parent 3994373387
commit c81654d769
3 changed files with 17 additions and 3 deletions

View File

@ -43,7 +43,7 @@ data class LocationData(
val latitude = geoParts?.firstOrNull() val latitude = geoParts?.firstOrNull()
val geoTailParts = geoParts?.getOrNull(1)?.split(";") val geoTailParts = geoParts?.getOrNull(1)?.split(";")
val longitude = geoTailParts?.firstOrNull() val longitude = geoTailParts?.firstOrNull()
val uncertainty = geoTailParts?.getOrNull(1) val uncertainty = geoTailParts?.getOrNull(1)?.replace("u=", "")
return if (latitude != null && longitude != null) { return if (latitude != null && longitude != null) {
LocationData( LocationData(

View File

@ -49,6 +49,11 @@ class LocationPreviewFragment @Inject constructor(
} }
} }
override fun onPause() {
views.mapView.onPause()
super.onPause()
}
override fun getMenuRes() = R.menu.menu_location_preview override fun getMenuRes() = R.menu.menu_location_preview
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
@ -67,6 +72,8 @@ class LocationPreviewFragment @Inject constructor(
} }
private fun onMapReady() { private fun onMapReady() {
if (!isAdded) return
val location = args.initialLocationData ?: return val location = args.initialLocationData ?: return
val userId = args.locationOwnerId val userId = args.locationOwnerId

View File

@ -69,12 +69,19 @@ class LocationSharingFragment @Inject constructor(
} }
} }
override fun onDestroyView() { override fun onPause() {
super.onDestroyView() views.mapView.onPause()
super.onPause()
}
override fun onDestroy() {
super.onDestroy()
locationTracker.stop() locationTracker.stop()
} }
private fun onMapReady() { private fun onMapReady() {
if (!isAdded) return
locationPinProvider.create(session.myUserId) { locationPinProvider.create(session.myUserId) {
views.mapView.addPinToMap( views.mapView.addPinToMap(
pinId = USER_PIN_NAME, pinId = USER_PIN_NAME,