Conversation
68760e9 to
d8a306e
Compare
| inline fun <reified T : Layer> StyleManagerInterface.getLayerAs(layerId: String): T? { | ||
| val layer = getLayer(layerId) | ||
| if (layer !is T) { | ||
| Logger.e("StyleLayerPlugin", "Given layerId = $layerId is not requested type in Layer") |
There was a problem hiding this comment.
nit: introduce TAG in companion object and use that as first parameter of Logger.e (I do think we had a convention of prefixing with mbgl_ but better to check the codebase).
There was a problem hiding this comment.
Given layerId = $layerId is not requested type in Layer the error statement is a bit confusing.
The layer itself could also just be null
There was a problem hiding this comment.
Any suggestion for error message ? :D
There was a problem hiding this comment.
nit: introduce TAG in companion object and use that as first parameter of Logger.e (I do think we had a convention of prefixing with mbgl_ but better to check the codebase).
actually, this is not a class, it's an extension function file.
There was a problem hiding this comment.
Could we do something as:
private const val TAG = "mgbl-LayerUtils"
at bottom or top of file?
LayerUtils naming comes from the java name of the LayerExt file.
8cdceda to
4c10161
Compare
| } No newline at end of file | ||
| } | ||
|
|
||
| const val TAG = "Mbgl-LayerUtils" No newline at end of file |
There was a problem hiding this comment.
could be made private? We might be leaking this tag if not?
There was a problem hiding this comment.
getLayerAs is a public inline function, which cannot use Private / internal declarations.
Although I can use @PublishedApi annotation to make TAG internal and let the function use it. but basically, that would be public TAG in a way.
There was a problem hiding this comment.
Fixed by annotating TAG with @PublishedApi in order to use it in public inline function getLayerAs.
4c10161 to
e947591
Compare
|
@ank27 how does it all look from Java side? |
|
|
Awesome! |
PRs must be submitted under the terms of our Contributor License Agreement CLA.
Fixes: < Link to related issues that will be fixed by this pull request, if they exist >
Pull request checklist:
mapbox-maps-androidchangelog:<changelog>Update getLayerAs function to return nullable Layer type.</changelog>.Summary of changes
Currently
StyleMangerInterface.getLayerAshas return type which is non-nullable.It should be a nullable type.
User impact (optional)
Breaking change to get layer from style using
getLayerAsfunction.Changed to