Back to project page BehatReporter.
The source code is released under:
Copyright (C) 2013 Fabian Kiss <headrevision@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software...
If you think the Android project BehatReporter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package headrevision.BehatReporter; /* ww w . ja va 2s. com*/ import headrevision.BehatReporter.json.ParserException; import headrevision.BehatReporter.report.ItemParser; import headrevision.BehatReporter.report.ItemsAdapter; import headrevision.BehatReporter.report.ItemsAdapterFactory; import headrevision.BehatReporter.ui.ItemDepth; import headrevision.BehatReporter.ui.Message; import java.util.List; import android.app.Activity; import android.widget.ExpandableListView; import android.widget.ExpandableListView.OnChildClickListener; import com.fasterxml.jackson.databind.JsonNode; public class ItemHandler { private static ItemHandler instance; private Activity activity; private ItemHandler(Activity activity) { this.activity = activity; } public static ItemHandler getInstance(Activity activity) { if (instance == null || instance.activity != activity) { instance = new ItemHandler(activity); } return instance; } public void show(ExpandableListView parent, int groupPosition, int childPosition, OnChildClickListener listener) { ItemsAdapter itemsAdapter = (ItemsAdapter) parent.getExpandableListAdapter(); JsonNode item = itemsAdapter.getChild(groupPosition, childPosition); ItemParser itemParser = itemsAdapter.getItemParserFactory().getItemParser(item); showSubItems(itemsAdapter, item, itemParser, listener); } private void showSubItems(ItemsAdapter itemsAdapter, JsonNode item, ItemParser itemParser, OnChildClickListener listener) { if (itemParser.hasSubItems()) { List<JsonNode> subItems = getSubItems(itemParser); if (subItems != null) { ItemsAdapterFactory subItemsAdapterFactory = itemsAdapter.getSubItemsAdapterFactory(item); ListHandler.getInstance(activity).show(itemParser, subItems, subItemsAdapterFactory, listener); ItemDepth.getInstance(activity).stepForward(); } } } private List<JsonNode> getSubItems(ItemParser itemParser) { List<JsonNode> subItems = null; try { subItems = itemParser.parseSubItems(); } catch (ParserException e) { Message.getInstance(activity).showError(e); } return subItems; } }