@Override
 public Set<Rect> getRectsForNodeHighlight() {
   Set<Rect> rects = new HashSet<>();
   for (OptionScanNode child : mChildren) {
     rects.addAll(child.getRectsForNodeHighlight());
   }
   return Collections.unmodifiableSet(rects);
 }
 /**
  * Selection nodes must be constructed with at least two things to select between
  *
  * @param child0 The first item to select
  * @param child1 The second item to select
  * @param otherChildren Any other items to select
  */
 public OptionScanSelectionNode(
     OptionScanNode child0, OptionScanNode child1, OptionScanNode... otherChildren) {
   mChildren = new OptionScanNode[otherChildren.length + 2];
   mChildren[0] = child0;
   mChildren[1] = child1;
   System.arraycopy(otherChildren, 0, mChildren, 2, otherChildren.length);
   for (OptionScanNode child : mChildren) {
     child.setParent(this);
   }
 }
 @Override
 public boolean equals(Object other) {
   if (!(other instanceof OptionScanSelectionNode)) {
     return false;
   }
   OptionScanSelectionNode otherNode = (OptionScanSelectionNode) other;
   if (otherNode.getChildCount() != getChildCount()) {
     return false;
   }
   for (int i = 0; i < mChildren.length; i++) {
     OptionScanNode child = mChildren[i];
     if (!child.equals(otherNode.getChild(i))) {
       return false;
     }
   }
   return true;
 }
Пример #4
0
 /**
  * Print a tree to a specified stream. This method is intended for debugging.
  *
  * @param tree The tree to print
  * @param printStream The stream to which to print
  * @param prefix Any prefix that should be prepended to each line.
  */
 @SuppressWarnings("unused")
 public static void printTree(OptionScanNode tree, PrintStream printStream, String prefix) {
   String treeClassName = tree.getClass().getSimpleName();
   if (tree instanceof AccessibilityNodeActionNode) {
     Iterator<Rect> rects = tree.getRectsForNodeHighlight().iterator();
     if (rects.hasNext()) {
       Rect rect = rects.next();
       printStream.println(prefix + treeClassName + " with rect: " + rect.toString());
     }
     return;
   }
   printStream.println(prefix + treeClassName);
   if (tree instanceof OptionScanSelectionNode) {
     OptionScanSelectionNode selectionNode = (OptionScanSelectionNode) tree;
     for (int i = 0; i < selectionNode.getChildCount(); ++i) {
       printTree(selectionNode.getChild(i), printStream, prefix + "-");
     }
   }
 }
 @Override
 public void recycle() {
   for (OptionScanNode child : mChildren) {
     child.recycle();
   }
 }