-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor native Map and Style to log error and not throw exception #1230
Changes from all commits
9ca4163
2bb16f0
0ffb3ba
da0a2c8
9fa1ae5
5ec87cb
01fd8f2
e59e356
9112623
3cd7be1
f26c591
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,11 @@ import com.mapbox.maps.extension.style.utils.silentUnwrap | |
fun StyleManagerInterface.getSource(sourceId: String): Source? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not in this release, but would consider to directly extend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
return this.getStyleSourceProperty(sourceId, "type").silentUnwrap<String>()?.let { type -> | ||
when (type) { | ||
"vector" -> VectorSource.Builder(sourceId).build().also { it.delegate = this } | ||
"geojson" -> GeoJsonSource.Builder(sourceId).build().also { it.delegate = this } | ||
"image" -> ImageSource.Builder(sourceId).build().also { it.delegate = this } | ||
"raster-dem" -> RasterDemSource.Builder(sourceId).build().also { it.delegate = this } | ||
"raster" -> RasterSource.Builder(sourceId).build().also { it.delegate = this } | ||
"vector" -> VectorSource.Builder(sourceId).build().also { it.delegate = this as StyleInterface } | ||
"geojson" -> GeoJsonSource.Builder(sourceId).build().also { it.delegate = this as StyleInterface } | ||
"image" -> ImageSource.Builder(sourceId).build().also { it.delegate = this as StyleInterface } | ||
"raster-dem" -> RasterDemSource.Builder(sourceId).build().also { it.delegate = this as StyleInterface } | ||
"raster" -> RasterSource.Builder(sourceId).build().also { it.delegate = this as StyleInterface } | ||
else -> { | ||
Logger.e("StyleSourcePlugin", "Source type: $type unknown.") | ||
null | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,18 @@ interface StyleInterface : StyleManagerInterface { | |
*/ | ||
val pixelRatio: Float | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're 100% sure that interface is not implemented with any customer, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. StyleInterface is implemented in the SDK module itself, we allow user to overwrite the plugin implementations, but the SDK module itself shouldn't and couldn't be implemented by the end users. The cases I can think of user use the StyleInterface is that they could mock it in their tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pengdev sounds a bit strange to me still as we're operating with
so for an end user guess it makes sense to mock There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 didn't remember we return Style async instead of StyleInterface |
||
* Whether the Style instance is valid. | ||
* | ||
* Style becomes invalid after MapView.onDestroy() is invoked, | ||
* calling any method then could result in undefined behaviour and will print an error log. | ||
* | ||
* Keeping the reference to an invalid Style instance introduces significant native memory leak. | ||
kiryldz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* @return True if Style is valid and false otherwise. | ||
*/ | ||
fun isValid(): Boolean | ||
|
||
/** | ||
* Adds an image to be used in the style. This API can also be used for updating | ||
* an image. If the image \a id was already added, it gets replaced by the new image. | ||
|
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.
Would it make sense to add some error logs 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.
it's non-error situation - map destroyed while we were parsing so see no need in logs 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.
that code is not correct when using persistent layers, rollbacked in #1324