private boolean prepareListData() {
        Set<String> headers = new HashSet<>();
        listDataHeader = new ArrayList<String>();

        //category, content
        listDataChild = new HashMap<String, List<String>>();
        if (sampleFactory==null || additionActivitybasedSamples==null) {
            //getActivity().getSupportFragmentManager().popBackStack();
            return false;
        }
        //had this throw an NPE once after device rotation and a back button press.
        for (int a = 0; a < sampleFactory.count(); a++) {
            final BaseSampleFragment f = sampleFactory.getSample(a);
            titleSampleMap.put(f.getSampleTitle(), f);
            String clz = f.getClass().getCanonicalName();
            String[] bits=clz.split("\\.");
            String group = bits[bits.length-2];
            group=capitialize(group);

            headers.add(group);

            if (!listDataChild.containsKey(group)) {
                listDataChild.put(group, new ArrayList<String>());
            }
            listDataChild.get(group).add(f.getSampleTitle());
        }


        if (!additionActivitybasedSamples.isEmpty()) {
            listDataHeader.add("Activities");
            listDataChild.put("Activities", new ArrayList<String>());
            for (int a = 0; a < additionActivitybasedSamples.size(); a++) {
                listDataChild.get("Activities").add(additionActivitybasedSamples.get(a).getActivityTitle());
                titleSampleMap.put(additionActivitybasedSamples.get(a).getActivityTitle(), additionActivitybasedSamples.get(a));
            }
        }


        listDataHeader.addAll(headers);

        return true;
    }
private boolean prepareListData ( ) { Set < String > headers = new HashSet < > ( ) ; listDataHeader = new ArrayList < String > ( ) ; listDataChild = new HashMap < String , List < String > > ( ) ; if ( sampleFactory == null || additionActivitybasedSamples == null ) { return false ; } for ( int a = 0 ; a < sampleFactory . count ( ) ; a ++ ) { final BaseSampleFragment f = sampleFactory . getSample ( a ) ; titleSampleMap . put ( f . getSampleTitle ( ) , f ) ; String clz = f . getClass ( ) . getCanonicalName ( ) ; String [ ] bits = clz . split ( "\\." ) ; String group = bits [ bits . length - 2 ] ; group = capitialize ( group ) ; headers . add ( group ) ; if ( ! listDataChild . containsKey ( group ) ) { listDataChild . put ( group , new ArrayList < String > ( ) ) ; } listDataChild . get ( group ) . add ( f . getSampleTitle ( ) ) ; } if ( ! additionActivitybasedSamples . isEmpty ( ) ) { listDataHeader . add ( "Activities" ) ; listDataChild . put ( "Activities" , new ArrayList < String > ( ) ) ; for ( int a = 0 ; a < additionActivitybasedSamples . size ( ) ; a ++ ) { listDataChild . get ( "Activities" ) . add ( additionActivitybasedSamples . get ( a ) . getActivityTitle ( ) ) ; titleSampleMap . put ( additionActivitybasedSamples . get ( a ) . getActivityTitle ( ) , additionActivitybasedSamples . get ( a ) ) ; } } listDataHeader . addAll ( headers ) ; return true ; }
/*
Preparing the list data