Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 93ba48a

Browse files
committed
[android] - forward getMapAsync to map for fragment
1 parent d4cb498 commit 93ba48a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
7676
public void onViewCreated(View view, Bundle savedInstanceState) {
7777
super.onViewCreated(view, savedInstanceState);
7878
map.onCreate(savedInstanceState);
79+
if (onMapReadyCallback != null) {
80+
map.getMapAsync(onMapReadyCallback);
81+
}
7982
}
8083

8184
/**
@@ -85,7 +88,6 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
8588
public void onStart() {
8689
super.onStart();
8790
map.onStart();
88-
map.getMapAsync(onMapReadyCallback);
8991
}
9092

9193
/**
@@ -150,6 +152,10 @@ public void onDestroyView() {
150152
* @param onMapReadyCallback The callback to be invoked.
151153
*/
152154
public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) {
153-
this.onMapReadyCallback = onMapReadyCallback;
155+
if (map == null) {
156+
this.onMapReadyCallback = onMapReadyCallback;
157+
} else {
158+
map.getMapAsync(onMapReadyCallback);
159+
}
154160
}
155161
}

platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
7676
public void onViewCreated(View view, Bundle savedInstanceState) {
7777
super.onViewCreated(view, savedInstanceState);
7878
map.onCreate(savedInstanceState);
79+
if (onMapReadyCallback != null) {
80+
map.getMapAsync(onMapReadyCallback);
81+
}
7982
}
8083

8184
/**
@@ -85,7 +88,6 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
8588
public void onStart() {
8689
super.onStart();
8790
map.onStart();
88-
map.getMapAsync(onMapReadyCallback);
8991
}
9092

9193
/**
@@ -150,6 +152,10 @@ public void onDestroyView() {
150152
* @param onMapReadyCallback The callback to be invoked.
151153
*/
152154
public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) {
153-
this.onMapReadyCallback = onMapReadyCallback;
155+
if (map == null) {
156+
this.onMapReadyCallback = onMapReadyCallback;
157+
} else {
158+
map.getMapAsync(onMapReadyCallback);
159+
}
154160
}
155161
}

0 commit comments

Comments
 (0)