Consolidate InstructionView DistanceFormatters #1174
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1169
Found a couple things stemming from the crash in the ticket. For context, the developer was using the
MapMatching
API, which looks like wasn't providing aRouteOptions#voiceUnit
. We were letting this pass all the way through to theInstructionListPresenter
which was eventually throwing an NPE.To fix this, I re-worked some of the logic around the
DistanceFormatter
inInstructionView
and created a new util for retrieving a non-nullString unitType
.We now ignore
null
unit types or languages and create a newDistanceFormatter
in theInstructionView
only when necessary. The presenter is then updated with the new formatter if needed.cc @riastrad