-
Notifications
You must be signed in to change notification settings - Fork 318
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
Fix backwards instructions in left-side driving scenarios #2044
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2044 +/- ##
===========================================
- Coverage 42.01% 41.5% -0.52%
- Complexity 1303 1348 +45
===========================================
Files 288 286 -2
Lines 9215 9127 -88
Branches 682 684 +2
===========================================
- Hits 3872 3788 -84
+ Misses 5022 5020 -2
+ Partials 321 319 -2 |
if (!STEP_MANEUVER_MODIFIER_LEFT.equals(drivingSide)) { | ||
drivingSide = EMPTY; | ||
if (STEP_MANEUVER_MODIFIER_LEFT.equals(drivingSide)) { | ||
if (STEP_MANEUVER_MODIFIER_UTURN.equals(maneuverModifier) |
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.
i wonder if we could reduce number (5) of nested if
conditions to improve readability of this method.
@@ -141,6 +141,21 @@ | |||
R.drawable.ic_maneuver_roundabout_straight); | |||
maneuverMap.put(STEP_MANEUVER_TYPE_ROUNDABOUT, R.drawable.ic_maneuver_roundabout); | |||
|
|||
maneuverMap.put(STEP_MANEUVER_TYPE_ROUNDABOUT + STEP_MANEUVER_MODIFIER_LEFT + STEP_MANEUVER_MODIFIER_LEFT, |
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.
what's the benefit of maintaining hashmap of the constants vs. simple switch-case
? also note is that ManeuverMap
constructor is not private, which may potentially result in multiple instances of the ManeuverMap
object created accidentally.
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.
what's the benefit of maintaining hashmap of the constants vs. simple
switch-case
?
In general, switch statements are considered a bad smell 👀 https://refactoring.guru/smells/switch-statements
Most of the times a switch statement can be easily replaced with map / dictionary.
And yeah, it's true there’s probably a bit more overhead in the dictionary than in the switch statement because you have to store the dictionary somewhere so it’s obviously using some memory. However IMO, in return you’re getting clean, concise, less error-prone and well-organized code that helps maintainability in the long term.
if (drivingSide.equals(STEP_MANEUVER_MODIFIER_RIGHT)) { | ||
boolean flip = SHOULD_FLIP_MODIFIERS.contains(maneuverModifier); | ||
setScaleX(flip ? -1 : 1); | ||
boolean flip = SHOULD_FLIP_MODIFIERS.contains(maneuverModifier); |
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.
is this equivalent to:
boolean flip = SHOULD_FLIP_MODIFIERS.contains(maneuverModifier); | |
boolean flip = SHOULD_FLIP_MODIFIERS.contains(maneuverModifier); | |
if (STEP_MANEUVER_MODIFIER_LEFT.equals(drivingSide) && STEP_MANEUVER_MODIFIER_UTURN.contains(maneuverModifier)) { | |
setScaleX(flip ? 1 : -1); | |
} else { | |
setScaleX(flip ? -1 : 1); | |
} |
I'm still testing multiple scenarios in different countries, I'll report back here and let you know when this is ready for review. |
One thing that I noticed during testing is that the source of the data that we're using for the banner and the notification is different 👀
Lines 493 to 502 in 71fae58
and Lines 274 to 281 in 71fae58
For consistency, we should revisit / consolidate this using the banner information in a feature PR. Refs. #1946 (comment) |
de02f59
to
f572154
Compare
IMO, objects and methods should live / be where their context is. From my experience utility classes become a drawer easily and we should treat them carefully. So I went ahead and removed This is now ready for review @andrlee @abhishek1508 @olegzil |
105bfc1
to
fa0bfb1
Compare
fa0bfb1
to
9d01b99
Compare
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.
LGTM!
@Guardiola31337, To be honest, I was using this class to retrieve to the icon resource in order to implement our upcoming/follow up leg design. |
Hey @Christophe668 thanks for your feedback.
As commented in #2044 (comment) we should consolidate the data source for the banner and the notification, in favor of using the banner information. Also mentioning that the logic changed is used for generating the As you may know, all this data can be retrieved from the In any case, could you talk more about your specific use case? We'd love to make sure we're not missing anything. Thanks again! |
Description
Fixes backwards instructions in left-side driving scenarios.
Fixes #396 and a regression from #1946
bug
,feature
,new API(s)
,SEMVER
, etc.)Goal
Maneuvers images (both the maneuver view and the notification maneuver icon) should be displayed accordingly in left-side driving countries.
Implementation
Fixed
ManeuverView
regression and added new notification maneuver icons and logic for left driving side 👀ManeuverUtils#getManeuverResource
Testing
Please describe the manual tests that you ran to verify your changes
SNAPSHOT
upstream dependencies if needed) through testapp/demo app and run all activities to avoid regressionsChecklist
CHANGELOG
including this PRcc @1ec5