-
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
Milestone #84
Milestone #84
Conversation
A few questions to better understand the flexibility being provided here, with an eye toward potentially implementing an analogous system on iOS using predicates or callbacks as part of mapbox/mapbox-navigation-ios#224:
|
Milestone milestone = new StepMilestone.Builder()
.setIdentifier(MY_MILESTONE)
.setTrigger(Trigger.all(
Trigger.lte(TriggerProperty.STEP_DISTANCE_TOTAL, 1609.34d), // Mile converted to meters
Trigger.gt(TriggerProperty.NEXT_STEP_DURATION, 5)// NEXT_STEP_DURATION property doesn't exist yet.
)).build();
|
How does that distinguish between exit ramp maneuvers and other maneuver types? Or is that out of scope for this design? |
In the future, we could always add triggers for specific milestones, currently, it is a simple implementation that was designed to match the behavior of the alert levels logic. |
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 is a fantastic PR, very excited to see this landing soon. Just a few small comments.
Timber.d("Milestone Event Occurred with id: %d", identifier); | ||
switch (identifier) { | ||
case NavigationConstants.URGENT_MILESTONE: | ||
Toast.makeText(this, "High Milestone", Toast.LENGTH_LONG).show(); |
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.
Toast text doesn't match the milestone constant.
Toast.makeText(this, "High Milestone", Toast.LENGTH_LONG).show(); | ||
break; | ||
case NavigationConstants.IMMINENT_MILESTONE: | ||
Toast.makeText(this, "Medium Milestone", Toast.LENGTH_LONG).show(); |
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.
Toast text doesn't match the milestone constant.
case NavigationConstants.ARRIVAL_MILESTONE: | ||
Toast.makeText(this, "Arrival", Toast.LENGTH_LONG).show(); | ||
break; | ||
default: |
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.
Can we make the milestone constants above an IntDef
enum to make the default case unnecessary? Or is this a possibility? (in which case we'd need to show a Toast too).
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 added the default for checkstyle to be happy. Looking back, it makes more sense to show a toast for the cases when the user adds a new milestone but doesn't do anything with it inside the switch statement.
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.
@cammace 👍 let's add a Toast with some generic text then.
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.
Added the toast on line 213, Github's just not showing it in the snippet above.
private void addDefaultMilestones() { | ||
// High milestone | ||
addMilestone(new StepMilestone.Builder() | ||
.setIdentifier(NavigationConstants.URGENT_MILESTONE) |
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.
Comment text doesn't match text in constant.
|
||
// Medium milestone | ||
addMilestone(new StepMilestone.Builder() | ||
.setIdentifier(NavigationConstants.IMMINENT_MILESTONE) |
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.
Comment text doesn't match text in constant.
* @return true if the milestone trigger's valid, else false | ||
* @since 0.4.0 | ||
*/ | ||
public abstract boolean validate(RouteProgress previousRouteProgress, RouteProgress routeProgress); |
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 does valid
means in this context? That the milestone is properly constructed, or that the milestone is happening? If the latter, I think I'd change validate
with something else. Considering it's a boolean, maybe something like milestone.isOccurring
?
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 like your naming much better 😄
} | ||
|
||
static boolean notEqual(Number[] valueOne, Number valueTwo) { | ||
|
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.
Nit: extra line.
package com.mapbox.services.android.navigation.v5.milestone; | ||
|
||
|
||
class Operation { |
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.
Even if this class isn't public
I think it'd benefit from comment code.
|
||
@Override | ||
public boolean validate(RouteProgress previousRouteProgress, RouteProgress routeProgress) { | ||
|
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.
Nit: extra line.
|
||
import java.util.Map; | ||
|
||
public class Trigger { |
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.
Missing Javadoc.
This PR removes the alert levels in favor of a more robust system called milestones. Milestones are more abstract, use the dsl pattern, offering some of the features listed below:
An example of creating a milestone's given below. An identifier's provided to later determine what milestone got triggered in the callback and the triggers. In this case, the milestones triggered only when all 3 of the conditions are true.
TriggerProperties
cc: @mapbox/navigation