use of org.onebusaway.phone.actions.search.NavigationBean in project onebusaway-application-modules by camsys.
the class StopsForRouteNavigationTemplate method buildTemplate.
@Override
public void buildTemplate(ActionContext context) {
ValueStack vs = context.getValueStack();
NavigationBean navigation = (NavigationBean) vs.findValue("navigation");
List<NameBean> names = navigation.getNames();
int index = navigation.getCurrentIndex();
if (index < 0)
index = 0;
/**
* We always listen for the key-press for the previous name in case it takes
* the user a second to press
*/
if (index > 0)
addNavigationSelectionActionForIndex(navigation, index - 1);
/**
* If we're at the first entry and there is a second, we allow the user to
* jump ahead
*/
if (index == 0 && names.size() > 1) {
addNavigationSelectionActionForIndex(navigation, index + 1);
}
if (index >= names.size()) {
AgiActionName action = setNextAction("/search/navigate-to");
action.putParam("navigation", navigation);
action.putParam("index", 0);
action.setExcludeFromHistory(true);
// Add an extra pause so the user has a chance to make a selection from
// the previous entry
addPause(1000);
addMessage(Messages.TO_REPEAT);
} else {
String key = addNavigationSelectionActionForIndex(navigation, index);
NameBean name = names.get(index);
handleName(name, key);
addNavigateToAction(navigation, "4", first(index - 1));
addNavigateToAction(navigation, "6", index + 1);
addNavigateToAction(navigation, "7", first(index - 10));
addNavigateToAction(navigation, "9", index + 10);
AgiActionName action = setNextAction("/search/navigate-to");
action.putParam("navigation", navigation);
action.putParam("index", index + 1);
action.setExcludeFromHistory(true);
}
addAction("\\*", "/back");
}
Aggregations