/** * add the section tabs for different segment structures. For example in Genesis these can be: * Chapters | Parshas | Commentary * * @param nodeList */ private void addTabsection(List<BilingualNode> nodeList) { tabRoot = new LinearLayout(context); tabRoot.setOrientation(LinearLayout.HORIZONTAL); tabRoot.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tabRoot.setGravity(Gravity.CENTER); this.addView(tabRoot, 0); // make sure it's on top for (int count = 0; count < nodeList.size(); count++) { MenuNode menuNode = (MenuNode) nodeList.get(count); // although generally this isn't necessary b/c the nodes come from menuState.getSections // this is used when rebuilding after memory dump and nodes come from setHasTabs() if (menuNode.getTitle(Util.Lang.EN).equals("Commentary") || (menuNode.getTitle(Util.Lang.EN).equals("Rif"))) { continue; } if (count > 0 && count < nodeList.size()) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.tab_divider_menu, tabRoot); } MenuButtonTab mbt = new MenuButtonTab(context, menuNode, menuState.getLang()); mbt.setOnClickListener(tabButtonClick); tabRoot.addView(mbt); menuElementList.add(mbt); menuButtonTabList.add(mbt); } }
@Override public void onClick(View v) { MenuButtonTab mbt = (MenuButtonTab) v; for (MenuButtonTab tempMBT : menuButtonTabList) tempMBT.setActive(false); mbt.setActive(true); gridRoot.removeAllViews(); menuState = menuState.goBack(false, false); menuState = menuState.goForward(mbt.getNode(), null); menuElementList = new ArrayList<>(); List<BilingualNode> sections = new ArrayList<>(); List<List<BilingualNode>> subsections = new ArrayList<>(); List<BilingualNode> nonSections = new ArrayList<>(); menuState.getPageSections(sections, subsections, nonSections); for (int i = 0; i < sections.size(); i++) { addSubsection((MenuNode) sections.get(i), subsections.get(i), false, i == 0); } addSubsection(null, nonSections, false, false); // don't flip tabs b/c they're already flipped if (flippedForHe) flipViews(false); }