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

Commit

Permalink
[android] - forward getMapAsync to map for fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Jul 26, 2017
1 parent d4cb498 commit 93ba48a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
map.onCreate(savedInstanceState);
if (onMapReadyCallback != null) {
map.getMapAsync(onMapReadyCallback);
}
}

/**
Expand All @@ -85,7 +88,6 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
public void onStart() {
super.onStart();
map.onStart();
map.getMapAsync(onMapReadyCallback);
}

/**
Expand Down Expand Up @@ -150,6 +152,10 @@ public void onDestroyView() {
* @param onMapReadyCallback The callback to be invoked.
*/
public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) {
this.onMapReadyCallback = onMapReadyCallback;
if (map == null) {
this.onMapReadyCallback = onMapReadyCallback;
} else {
map.getMapAsync(onMapReadyCallback);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
map.onCreate(savedInstanceState);
if (onMapReadyCallback != null) {
map.getMapAsync(onMapReadyCallback);
}
}

/**
Expand All @@ -85,7 +88,6 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
public void onStart() {
super.onStart();
map.onStart();
map.getMapAsync(onMapReadyCallback);
}

/**
Expand Down Expand Up @@ -150,6 +152,10 @@ public void onDestroyView() {
* @param onMapReadyCallback The callback to be invoked.
*/
public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) {
this.onMapReadyCallback = onMapReadyCallback;
if (map == null) {
this.onMapReadyCallback = onMapReadyCallback;
} else {
map.getMapAsync(onMapReadyCallback);
}
}
}

0 comments on commit 93ba48a

Please sign in to comment.