private int calculateSize(Category category, int page) { // TODO: Calculate this amount based on no of packages int needed = 45; // bottom row if (!category.getSubcategories().isEmpty()) { int pagesWithSubcats = (int) Math.ceil(category.getSubcategories().size() / 9D); if (pagesWithSubcats >= page) { // more pages exist needed += 9; } } // if we show subcategories, we can't show as many pages return needed; }
private static int calculatePages(Category category) { int pagesWithSubcats = (int) Math.ceil(category.getSubcategories().size() / 9D); int pagesWithPackages = (int) Math.ceil(category.getPackages().size() / 36D); return Math.max(pagesWithSubcats, pagesWithPackages); }
private Package doSearch(int id, Category category) { for (Package aPackage : category.getPackages()) { if (aPackage.getId() == id) return aPackage; } for (Category sub : category.getSubcategories()) { Package p = doSearch(id, sub); if (p != null) return p; } return null; } }
public Node getChild(Category subcategory) { return new Node(subcategory.getSubcategories(), subcategory.getPackages(), subcategory.getName(), this); }
public void update() { if (plugin.getApiClient() == null || plugin.getServerInformation() == null) { plugin.getLogger().warning("No secret key available (or no server information), so can't update inventories."); return; } Listing listing = plugin.getListingUpdateTask().getListing(); if (listing == null) { plugin.getLogger().warning("No listing found, so can't update inventories."); return; } List<Integer> foundIds = new ArrayList<>(); for (Category category : listing.getCategories()) { foundIds.add(category.getId()); for (Category category1 : category.getSubcategories()) { foundIds.add(category1.getId()); } } for (Iterator<Map.Entry<Integer, List<GUIImpl>>> it = categoryMenus.entrySet().iterator(); it.hasNext(); ) { Map.Entry<Integer, List<GUIImpl>> next = it.next(); if (!foundIds.contains(next.getKey())) { for (GUIImpl gui : next.getValue()) { gui.destroy(); } it.remove(); } } for (Category category : listing.getCategories()) { doUpdate(null, category); } }
for (Category category1 : category.getSubcategories()) { doUpdate(category, category1);
if (!category.getSubcategories().isEmpty()) { subcatPartition = Lists.partition(category.getSubcategories(), 45); if (subcatPartition.size() - 1 >= page) { List<Category> subcats = subcatPartition.get(page);
if (displayName.startsWith(ChatColor.YELLOW.toString())) { for (final Category category1 : category.getSubcategories()) { if (category1.getName().equals(ChatColor.stripColor(displayName))) { final GUIImpl gui = getFirstPage(category1);