summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2019-03-05 10:33:03 +0100
committerTobrun <tobrun@mapbox.com>2019-03-06 14:18:05 +0100
commitbe75dc9a48764850ebb52e3bab7ae08b3370cd09 (patch)
tree6a05561404cd6870562da0f68401322b45ec9e00
parent383fde6804b0865dce6aaf22394509722845c33f (diff)
downloadqtlocation-mapboxgl-be75dc9a48764850ebb52e3bab7ae08b3370cd09.tar.gz
[android] - clear callbacks as part of OnDestroy not as part of OnDestroyView
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java8
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/FragmentBackStackActivity.kt45
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_backstack_fragment.xml15
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml3
-rw-r--r--platform/android/scripts/exclude-activity-gen.json3
8 files changed, 94 insertions, 7 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java
index 2ad4837bb7..8af9f2c6a8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java
@@ -198,6 +198,14 @@ public final class MapFragment extends Fragment implements OnMapReadyCallback {
public void onDestroyView() {
super.onDestroyView();
map.onDestroy();
+ }
+
+ /**
+ * Called when the fragment is destroyed.
+ */
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
mapReadyCallbackList.clear();
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java
index e3155c417b..011a0bdaa2 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java
@@ -187,12 +187,20 @@ public class SupportMapFragment extends Fragment implements OnMapReadyCallback {
}
/**
- * Called when the fragment is view hiearchy is being destroyed.
+ * Called when the fragment is view hierarchy is being destroyed.
*/
@Override
public void onDestroyView() {
super.onDestroyView();
map.onDestroy();
+ }
+
+ /**
+ * Called when the fragment is destroyed.
+ */
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
mapReadyCallbackList.clear();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index a113fe1d6b..c8986d6775 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -162,7 +162,7 @@
<activity
android:name=".activity.fragment.SupportMapFragmentActivity"
android:description="@string/description_map_fragment_support"
- android:label="@string/activity_map_fragment_suport">
+ android:label="@string/activity_map_fragment_support">
<meta-data
android:name="@string/category"
android:value="@string/category_fragment" />
@@ -171,6 +171,17 @@
android:value=".activity.FeatureOverviewActivity" />
</activity>
<activity
+ android:name=".activity.fragment.FragmentBackStackActivity"
+ android:description="@string/description_map_fragment_backstack"
+ android:label="@string/activity_map_fragment_backstack">
+ <meta-data
+ android:name="@string/category"
+ android:value="@string/category_fragment" />
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value=".activity.FeatureOverviewActivity" />
+ </activity>
+ <activity
android:name=".activity.fragment.MultiMapActivity"
android:description="@string/description_multimap"
android:label="@string/activity_multimap">
@@ -896,9 +907,6 @@
</activity>
<!-- For Instrumentation tests -->
<activity
- android:name=".activity.style.RuntimeStyleTestActivity"
- android:screenOrientation="portrait" />
- <activity
android:name=".activity.style.RuntimeStyleTimingTestActivity"
android:screenOrientation="portrait" />
<activity
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/FragmentBackStackActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/FragmentBackStackActivity.kt
new file mode 100644
index 0000000000..be4d3d2f1b
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/FragmentBackStackActivity.kt
@@ -0,0 +1,45 @@
+package com.mapbox.mapboxsdk.testapp.activity.fragment
+
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.view.View
+import com.mapbox.mapboxsdk.maps.MapboxMap
+import com.mapbox.mapboxsdk.maps.Style
+import com.mapbox.mapboxsdk.maps.SupportMapFragment
+import com.mapbox.mapboxsdk.testapp.R
+import kotlinx.android.synthetic.main.activity_backstack_fragment.*
+
+/**
+ * Test activity showcasing using the MapFragment API as part of a backstacked fragment.
+ */
+class FragmentBackStackActivity : AppCompatActivity() {
+
+ private lateinit var mapFragment: SupportMapFragment
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_backstack_fragment)
+
+ mapFragment = SupportMapFragment.newInstance()
+ mapFragment.getMapAsync { initMap(it) }
+
+ supportFragmentManager.beginTransaction().apply {
+ add(R.id.container, mapFragment)
+ }.commit()
+
+ button.setOnClickListener { handleClick(it) }
+ }
+
+ private fun initMap(mapboxMap: MapboxMap) {
+ mapboxMap.setStyle(Style.SATELLITE) {
+ mapboxMap.setPadding(300, 300, 300, 300)
+ }
+ }
+
+ private fun handleClick(button: View) {
+ supportFragmentManager.beginTransaction().apply {
+ replace(R.id.container, NestedViewPagerActivity.ItemAdapter.EmptyFragment())
+ addToBackStack("map_empty_fragment")
+ }.commit()
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_backstack_fragment.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_backstack_fragment.xml
new file mode 100644
index 0000000000..b6b672cf73
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_backstack_fragment.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <FrameLayout android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+ <Button android:layout_width="match_parent"
+ android:layout_height="58dp"
+ android:id="@+id/button"
+ android:text="Replace with empty fragment"/>
+
+</FrameLayout> \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
index 14eb678795..40698eae78 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
@@ -5,6 +5,7 @@
<string name="description_cameraposition">CameraPosition capabilities</string>
<string name="description_map_fragment">Showcase MapFragment</string>
<string name="description_map_fragment_support">Showcase SupportMapFragment</string>
+ <string name="description_map_fragment_backstack">Showcase using a Map Fragment with a fragment backstack</string>
<string name="description_multimap">Activity with multiple maps on screen</string>
<string name="description_press_for_marker">Add marker to map on long press</string>
<string name="description_camera_zoom">Different types of zoom methods</string>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
index dc4fd89deb..290a157dd1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="activity_map_fragment_suport">Support Map Fragment</string>
+ <string name="activity_map_fragment_support">Support Map Fragment</string>
<string name="activity_map_fragment">Map Fragment</string>
+ <string name="activity_map_fragment_backstack">Backstack Map Fragment</string>
<string name="activity_multimap">Multiple Maps on Screen</string>
<string name="activity_add_bulk_markers">Add Markers In Bulk</string>
<string name="activity_animated_symbollayer">Animated SymbolLayer</string>
diff --git a/platform/android/scripts/exclude-activity-gen.json b/platform/android/scripts/exclude-activity-gen.json
index 2a70b47c65..841a04e5f1 100644
--- a/platform/android/scripts/exclude-activity-gen.json
+++ b/platform/android/scripts/exclude-activity-gen.json
@@ -45,5 +45,6 @@
"RuntimeStyleActivity",
"GridSourceActivity",
"AnimatedImageSourceActivity",
- "EspressoTestActivity"
+ "EspressoTestActivity",
+ "FragmentBackStackActivity"
]