Skip to content

Commit

Permalink
Check dispatcher on announcement and instruction events in Navigation…
Browse files Browse the repository at this point in the history
…ViewModel
  • Loading branch information
danesfeder committed Jul 24, 2018
1 parent d4b366f commit 627f23d
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@ private void playVoiceAnnouncement(Milestone milestone) {
if (milestone instanceof VoiceInstructionMilestone) {
SpeechAnnouncement announcement = SpeechAnnouncement.builder()
.voiceInstructionMilestone((VoiceInstructionMilestone) milestone).build();
announcement = navigationViewEventDispatcher.onAnnouncement(announcement);
announcement = retrieveAnnouncementFromSpeechEvent(announcement);
instructionPlayer.play(announcement);
}
}

private void updateBannerInstruction(RouteProgress routeProgress, Milestone milestone) {
if (milestone instanceof BannerInstructionMilestone) {
BannerInstructions instructions = ((BannerInstructionMilestone) milestone).getBannerInstructions();
instructions = navigationViewEventDispatcher.onBannerDisplay(instructions);
instructions = retrieveInstructionsFromBannerEvent(instructions);
if (instructions != null) {
BannerInstructionModel model = new BannerInstructionModel(getApplication(), instructions,
routeProgress, language, unitType);
Expand Down Expand Up @@ -433,4 +433,18 @@ private void sendEventOnRerouteAlong(DirectionsRoute route) {
navigationViewEventDispatcher.onRerouteAlong(route);
}
}

private SpeechAnnouncement retrieveAnnouncementFromSpeechEvent(SpeechAnnouncement announcement) {
if (navigationViewEventDispatcher != null) {
announcement = navigationViewEventDispatcher.onAnnouncement(announcement);
}
return announcement;
}

private BannerInstructions retrieveInstructionsFromBannerEvent(BannerInstructions instructions) {
if (navigationViewEventDispatcher != null) {
instructions = navigationViewEventDispatcher.onBannerDisplay(instructions);
}
return instructions;
}
}

0 comments on commit 627f23d

Please sign in to comment.