1.1.40 trying to squash native crash in mb via testlab.

This commit is contained in:
Kevin Hester
2021-02-02 10:47:54 +08:00
parent a618aba7f0
commit 4ea44095df
2 changed files with 18 additions and 7 deletions

View File

@@ -31,8 +31,8 @@ android {
applicationId "com.geeksville.mesh"
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 29
versionCode 20139 // format is Mmmss (where M is 1+the numeric major number
versionName "1.1.39"
versionCode 20140 // format is Mmmss (where M is 1+the numeric major number
versionName "1.1.40"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// per https://developer.android.com/studio/write/vector-asset-studio

View File

@@ -136,7 +136,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
* Mapbox native code can crash painfully if you ever call a mapbox view function while the view is not actively being show
*/
private val isViewVisible: Boolean
get() = view != null && isResumed
get() = view != null && isResumed && (mapView?.isDestroyed != false)
override fun onViewCreated(viewIn: View, savedInstanceState: Bundle?) {
super.onViewCreated(viewIn, savedInstanceState)
@@ -145,9 +145,9 @@ class MapFragment : ScreenFragment("Map"), Logging {
if ((requireContext().applicationContext as GeeksvilleApplication).isAnalyticsAllowed) {
val vIn = viewIn.findViewById<MapView>(R.id.mapView)
mapView = vIn
vIn.onCreate(savedInstanceState)
mapView?.let { v ->
v.onCreate(savedInstanceState)
// Each time the pane is shown start fetching new map info (we do this here instead of
// onCreate because getMapAsync can die in native code if the view goes away)
v.getMapAsync { map ->
@@ -205,14 +205,25 @@ class MapFragment : ScreenFragment("Map"), Logging {
}
override fun onDestroyView() {
mapView?.onDestroy()
super.onDestroyView()
mapView?.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle) {
mapView?.onSaveInstanceState(outState)
mapView?.let {
if (!it.isDestroyed)
it.onSaveInstanceState(outState)
}
super.onSaveInstanceState(outState)
}
override fun onLowMemory() {
mapView?.let {
if (!it.isDestroyed)
it.onLowMemory()
}
super.onLowMemory()
}
}