summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-10-18 15:19:04 +0200
committerTobrun <tobrun@mapbox.com>2018-11-14 16:25:10 +0100
commitbb5b558f21c56872127540c7c5b0324d6286e505 (patch)
tree993d8610032ef4a773a7baeab62a00c4da450c69 /platform
parent16c4c9a45c3018d0c9359776b127712e8d1bf416 (diff)
downloadqtlocation-mapboxgl-bb5b558f21c56872127540c7c5b0324d6286e505.tar.gz
[android] - harden activation/deactivation of underlying ref counting components
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java15
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt6
2 files changed, 16 insertions, 5 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index ca7fd213c9..10ac5a1bbe 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -89,6 +89,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
private MapKeyListener mapKeyListener;
@Nullable
private Bundle savedInstanceState;
+ private boolean isActivated;
@UiThread
public MapView(@NonNull Context context) {
@@ -345,8 +346,11 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
*/
@UiThread
public void onStart() {
- ConnectivityReceiver.instance(getContext()).activate();
- FileSource.getInstance(getContext()).activate();
+ if (!isActivated) {
+ ConnectivityReceiver.instance(getContext()).activate();
+ FileSource.getInstance(getContext()).activate();
+ isActivated = true;
+ }
if (mapboxMap != null) {
mapboxMap.onStart();
}
@@ -391,8 +395,11 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
mapRenderer.onStop();
}
- ConnectivityReceiver.instance(getContext()).deactivate();
- FileSource.getInstance(getContext()).deactivate();
+ if (isActivated) {
+ ConnectivityReceiver.instance(getContext()).deactivate();
+ FileSource.getInstance(getContext()).deactivate();
+ isActivated = false;
+ }
}
/**
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt
index 66e205b8a4..d35c977df0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt
@@ -120,7 +120,11 @@ class RecyclerViewActivity : AppCompatActivity() {
}
fun onDestroy() {
- mapHolder?.mapView?.onDestroy()
+ mapHolder?.mapView?.let {
+ it.onPause()
+ it.onStop()
+ it.onDestroy()
+ }
}
class MapItem