public Bundle execute(LinkLoadArgs linkArgs) { Channel channel = linkArgs.getChannel(); String channelTag = channel.getView(); List<String> pathParts = linkArgs.getPathParts(); Bundle args = null; switch (channelTag) { case "food": args = switchFood(pathParts); break; case "bus": args = switchBus(channel, pathParts); break; case "reader": args = switchReader(channel, pathParts); break; case "soc": args = switchSOC(pathParts); break; case "places": args = switchPlaces(pathParts); break; } if (args != null) { args.putBoolean(ComponentFactory.ARG_BACKSTACK_TAG, backstack); } return args; }
/** * @param channel bus channel * @param pathParts /route /stop /all /route/route-name /stop/stop-name * @return bundle to start this fragment */ public Bundle switchBus(Channel channel, List<String> pathParts) { if (pathParts.size() > 2) { return null; } // get the type of object to display: route, stop, or all String rsa = pathParts.remove(0); Integer startTab = LinkMaps.busPositions.get(rsa); if (startTab == null) { return null; } if (pathParts.size() == 0) { // no route or stop name given return BusMain.createArgs(channel.getTitle(homeCampus), startTab); } // link to the route or stop given String stopOrRoute = pathParts.remove(0); String mode; switch (startTab) { case 1: mode = BusDisplay.STOP_MODE; break; default: mode = BusDisplay.ROUTE_MODE; break; } return BusDisplay.createLinkArgs(mode, NextbusAPI.AGENCY_NB, stopOrRoute); }