Open
Description
We use this API to create FixLocation#extras
. The logic is simple: there are multiple predefined types, we use bundle.get
and check if the returned value is instance of one of the predefined types. If yes, create map entry with the following type, if no, ignore the entry. Code:
val key = iterator.next()
when (val value = this.get(key)) {
is Boolean -> map[key] = Value(value)
is Byte -> map[key] = Value(value.toLong())
is Char -> map[key] = Value(value.toString())
is Double -> map[key] = Value(value)
is Float -> map[key] = Value(value.toDouble())
is Int -> map[key] = Value(value.toLong())
is Long -> map[key] = Value(value)
is Short -> map[key] = Value(value.toLong())
is String -> map[key] = Value(value)
else -> {
logW(
"Unsupported type in location extras",
LOG_CATEGORY
)
}
}
Now Bundle#get
is deprecated and there is no other way to determine which type has the value by a concrete key. For now we can leave it as-is because deprecation is not removal, but it's very probable that in the future we'll have to face this problem anyway.
Questions:
- Where is
FixLocation#extras
used? We use it only to convert back toLocation#extras
. The whole object is passed toNavigator#updateLocation
. Are the extras somehow used there? I see that iOS does not have any extras. - Do we need all extras there or just some predefined ones? This way we can use type-safe methods like
Bundle#getString
if we know the key (and which type the value has).
cc @mapbox/navnative