-
Notifications
You must be signed in to change notification settings - Fork 319
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
Added InstructionViewCallback to allow views to be alerted when the in… #988
Conversation
@@ -78,7 +80,8 @@ private void startNavigation(DirectionsRoute directionsRoute) { | |||
.navigationListener(this) | |||
.directionsRoute(directionsRoute) | |||
.shouldSimulateRoute(true) | |||
.progressChangeListener(this); | |||
.progressChangeListener(this) |
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.
@devotaaabel did you notice EmbeddedNavigationActivity
being affected by #981?
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.
@danesfeder yea I think it was
@@ -152,4 +159,10 @@ private void assignMilestoneEventListener(NavigationViewOptions navigationViewOp | |||
navigation.addMilestoneEventListener(navigationViewOptions.milestoneEventListener()); | |||
} | |||
} | |||
|
|||
void onInstructionListShown(boolean shown) { |
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.
@@ -401,12 +402,29 @@ public MapboxMap getMapboxMap() { | |||
return map; | |||
} | |||
|
|||
public void setInstructionViewCallback() { |
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 method can be private
and we can be more specific in the naming initializeInstructionListListener
. I think aligning callback
and listener
here makes sense even though they are essentially the same.
@@ -401,12 +402,29 @@ public MapboxMap getMapboxMap() { | |||
return map; | |||
} | |||
|
|||
public void setInstructionViewCallback() { | |||
if (instructionView != null) { |
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.
Would the instructionView
ever be null
here? It's being bound right before this in NavigationView#bind()
instructionView.setInstructionListListener(new InstructionListListener() { | ||
@Override | ||
public void onInstructionListShown(boolean shown) { | ||
if (shown) { |
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 business logic can be extracted into NavigationPresenter
so we can call navigationPresenter.onInstructionListVisibilityChanged(isShowing)
. The show / hide recenter button are already view methods that the presenter has access to
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.
@danesfeder hmm maybe the dispatcher should reside in the presenter
if (instructionView != null) { | ||
instructionView.setInstructionListListener(new InstructionListListener() { | ||
@Override | ||
public void onInstructionListShown(boolean shown) { |
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.
It may make more sense to update the naming here to something like onInstructionListVisibilityChanged(boolean isShowing)
because the listener is fired for both the list showing and hiding and not just showing as the current naming may imply
ef33a5b
to
b513aa6
Compare
@danesfeder updated |
This comment has been minimized.
This comment has been minimized.
374a6ee
to
5c973dc
Compare
1e17bd1
to
7042e4d
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.
@devotaaabel looking great thank you, much cleaner with that logic in the presenter - two minor nitpicks before we 🚢
@@ -378,6 +379,7 @@ private void initializeView() { | |||
bind(); | |||
initializeNavigationViewModel(); | |||
initializeSummaryBottomSheet(); | |||
initializeInstructionListListener(); |
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 know it would be incredibly hard to cause this crash, but let's initialize this listener after the presenter/event dispatcher because they are being used within the listener
@@ -299,6 +305,9 @@ public void hideInstructionList() { | |||
updateLandscapeConstraintsTo(R.layout.instruction_layout); | |||
} | |||
instructionListLayout.setVisibility(GONE); | |||
if (instructionListListener != null) { |
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.
We can remove duplicate code here by creating a function that takes a boolean (duplicate code: L320-322
)
7042e4d
to
874f7fe
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.
Once CI is ✅, this looks good to go 🚢
…nstruction list is shown or hidden. This fixes the bugs where the re-center button and other widgets are shown on top of the instruction list when it's expanded
874f7fe
to
d9e0809
Compare
…struction list is shown or hidden. This fixes the bugs where the re-center button and other widgets are shown on top of the instruction list when it's expanded.