-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[android] - add style loading callback #8291
[android] - add style loading callback #8291
Conversation
} | ||
} | ||
}); | ||
} | ||
nativeMapView.setStyleUrl(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call this class's setStyleUrl()
in order to gate the native call through fewer (i.e. a single) places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@incanus That would be a circular reference and would cause a stack overflow
* <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li> | ||
* </ul> | ||
* <p> | ||
* This method is asynchronous and will return immediately before the style finishes loading. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and the similar comment(s) above) could be worded better—makes it sound like immediately before instead of what actually happens, which is immediately and before the style finishes loading.
* </ul> | ||
* <p> | ||
* This method is asynchronous and will return immediately before the style finishes loading. | ||
* If you wish to wait for the map to finish loading listen for the {@link MapView#DID_FINISH_LOADING_MAP} event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a ,
after loading
.
public void setStyleUrl(@NonNull final String url, @Nullable final OnStyleLoadedListener callback) { | ||
if (callback != null) { | ||
nativeMapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { | ||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be my Android newbness speaking, but do you need to call the superclass implementation if you are overriding here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@incanus It's an interface, not a class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Just my minor comment docs changes above, but this is good to ship. |
…tyle with the default styles.
Closes #8262.
This PR adds a style loading callback that is invoked when the style has finished loading.