/** Update the visible children on the state. */
  private void updateVisibleChildren(
      StackScrollState resultState, StackScrollAlgorithmState state) {
    Log.d(TAG, "updateVisibleChildren: ");
    ViewGroup hostView = resultState.getHostView();
    int childCount = hostView.getChildCount();
    state.visibleChildren.clear();
    state.visibleChildren.ensureCapacity(childCount);
    int notGoneIndex = 0;
    for (int i = 0; i < childCount; i++) {
      ExpandableView v = (ExpandableView) hostView.getChildAt(i);
      if (v.getVisibility() != View.GONE) {
        notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v);
        if (v instanceof ExpandableNotificationRow) {
          ExpandableNotificationRow row = (ExpandableNotificationRow) v;

          // handle the notgoneIndex for the children as well
          List<ExpandableNotificationRow> children = row.getNotificationChildren();
          if (row.areChildrenExpanded() && children != null) {
            for (ExpandableNotificationRow childRow : children) {
              if (childRow.getVisibility() != View.GONE) {
                StackViewState childState = resultState.getViewStateForView(childRow);
                childState.notGoneIndex = notGoneIndex;
                notGoneIndex++;
              }
            }
          }
        }
      }
    }
  }