private HashMap<Integer,Boolean> generateExpandedStateMap(List<Object> itemList){
  HashMap<Integer,Boolean> parentObjectHashMap=new HashMap<>();
  int childCount=0;
  for (int i=0; i < itemList.size(); i++) {
    if (itemList.get(i) != null) {
      Object helperItem=getHelperItem(i);
      if (helperItem instanceof ParentWrapper) {
        ParentWrapper parentWrapper=(ParentWrapper)helperItem;
        parentObjectHashMap.put(i - childCount,parentWrapper.isExpanded());
      }
 else {
        childCount++;
      }
    }
  }
  return parentObjectHashMap;
}

private HashMap < Integer , Boolean > generateExpandedStateMap ( List < Object > itemList ) { HashMap < Integer , Boolean > parentObjectHashMap = new HashMap < > ( ) ; int childCount = 0 ; for ( int i = 0 ; i < itemList . size ( ) ; i ++ ) { if ( itemList . get ( i ) != null ) { Object helperItem = getHelperItem ( i ) ; if ( helperItem instanceof ParentWrapper ) { ParentWrapper parentWrapper = ( ParentWrapper ) helperItem ; parentObjectHashMap . put ( i - childCount , parentWrapper . isExpanded ( ) ) ; } else { childCount ++ ; } } } return parentObjectHashMap ; }
generates a hashmap for storing expanded state when activity is rotated or onresume ( ) is called .
