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
Check Turn / Then Banner on each update #696
Conversation
danesfeder
commented
Feb 12, 2018
- Previously would only check when new step was found
- Fixes bug with then banner not showing after medium alert level
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.
Some minor comments to take into account before merging this PR
@@ -98,7 +98,7 @@ private void thenStep(LegStep upcomingStep, LegStep followOnStep, double current | |||
thenStepManeuverType = followOnStep.maneuver().type(); | |||
thenStepManeuverModifier = followOnStep.maneuver().modifier(); | |||
// Should show then step if the upcoming step is less than 25 seconds |
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.
This comment is now lying. This is an example of why I'm not a big fan of comments
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.
The best comment is a good name for a method or class.
or variable in this case 😛
👀 Code Smells 👉 Comments
@@ -98,7 +98,7 @@ private void thenStep(LegStep upcomingStep, LegStep followOnStep, double current | |||
thenStepManeuverType = followOnStep.maneuver().type(); | |||
thenStepManeuverModifier = followOnStep.maneuver().modifier(); | |||
// Should show then step if the upcoming step is less than 25 seconds | |||
shouldShowThenStep = upcomingStep.duration() <= (25d * 1.2d) && currentDurationRemaining <= (70d * 1.2d); | |||
shouldShowThenStep = upcomingStep.duration() <= (25d * 1.2d) && currentDurationRemaining <= 70d; |
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.
Could we fix the variable name to reflect what actually is doing? This way comment will become superfluous so it won't be necessary.
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 about decomposing conditional extracting that complicated expression into a well-named private
method? Conditionals tend to get more and more complicated in their logic over time.
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.
Magic numbers.
String maneuverViewModifier = model.getStepResources().getManeuverViewModifier(); | ||
double durationRemaining = model.getProgress().currentLegProgress().currentStepProgress().durationRemaining(); | ||
|
||
if (turnLanes != null && !TextUtils.isEmpty(maneuverViewModifier) && durationRemaining <= 70d) { |
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 about simplifying this conditional? 👀 Decompose Conditional
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.
Magic number.
- Allows us to show after medium alert level duration remaining
14c9d64
to
dd4ebd6
Compare
@Guardiola31337 Comments addressed 🍍 |
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.
Small comment not blocking the PR.
Great job
shouldShowThenStep = validStepDuration(upcomingStep, currentDurationRemaining); | ||
} | ||
|
||
private boolean validStepDuration(LegStep upcomingStep, double currentDurationRemaining) { |
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.
Minor detail, what about isValidStepDuration
instead?