Java Code Examples for android.view.accessibility.AccessibilityNodeInfo#equals()

The following examples show how to use android.view.accessibility.AccessibilityNodeInfo#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccessibilityNodeInfoUtils.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
private static AccessibilityNodeInfo refreshFromChild(
        AccessibilityNodeInfo node) {
    if (node.getChildCount() > 0) {
        AccessibilityNodeInfo firstChild = node.getChild(0);
        if (firstChild != null) {
            AccessibilityNodeInfo parent = firstChild.getParent();
            firstChild.recycle();
            if (node.equals(parent)) {
                return parent;
            } else {
                recycleNodes(parent);
            }
        }
    }
    return null;
}
 
Example 2
Source File: AccessibilityNodeInfoUtils.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
private static AccessibilityNodeInfo refreshFromParent(
        AccessibilityNodeInfo node) {
    AccessibilityNodeInfo parent = node.getParent();
    if (parent != null) {
        try {
            int childCount = parent.getChildCount();
            for (int i = 0; i < childCount; ++i) {
                AccessibilityNodeInfo child = parent.getChild(i);
                if (node.equals(child)) {
                    return child;
                }
                recycleNodes(child);
            }
        } finally {
            parent.recycle();
        }
    }
    return null;
}
 
Example 3
Source File: WindowManager.java    From talkback with Apache License 2.0 6 votes vote down vote up
/** Gets the window whose anchor equals the given node. */
public @Nullable AccessibilityWindowInfo getAnchoredWindow(
    @Nullable AccessibilityNodeInfoCompat targetAnchor) {
  if (!BuildVersionUtils.isAtLeastN() || targetAnchor == null) {
    return null;
  }

  int windowCount = mWindows.size();
  for (int i = 0; i < windowCount; ++i) {
    AccessibilityWindowInfo window = mWindows.get(i);
    if (window != null) {
      AccessibilityNodeInfo anchor = window.getAnchor();
      if (anchor != null) {
        try {
          if (anchor.equals(targetAnchor.unwrap())) {
            return window;
          }
        } finally {
          anchor.recycle();
        }
      }
    }
  }

  return null;
}
 
Example 4
Source File: TreeDebugNavigationMode.java    From brailleback with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfo getPreviousSibling(
    AccessibilityNodeInfo from) {
    AccessibilityNodeInfo ret = null;
    AccessibilityNodeInfo parent = from.getParent();
    if (parent == null) {
        return null;
    }
    AccessibilityNodeInfo prev = null;
    AccessibilityNodeInfo cur = null;
    try {
        int childCount = parent.getChildCount();
        for (int i = 0; i < childCount; ++i) {
            cur = parent.getChild(i);
            if (cur == null) {
                return null;
            }
            if (cur.equals(from)) {
                ret = prev;
                prev = null;
                return ret;
            }
            if (prev != null) {
                prev.recycle();
            }
            prev = cur;
            cur = null;
        }
    } finally {
        parent.recycle();
        if (prev != null) {
            prev.recycle();
        }
        if (cur != null) {
            cur.recycle();
        }
    }
    return ret;
}
 
Example 5
Source File: TreeDebugNavigationMode.java    From brailleback with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfo getNextSibling(
    AccessibilityNodeInfo from) {
    AccessibilityNodeInfo parent = from.getParent();
    if (parent == null) {
        return null;
    }
    AccessibilityNodeInfo cur = null;
    try {
        int childCount = parent.getChildCount();
        for (int i = 0; i < childCount - 1; ++i) {
            cur = parent.getChild(i);
            if (cur == null) {
                return null;
            }
            if (cur.equals(from)) {
                return parent.getChild(i + 1);
            }
            if (cur != null) {
                cur.recycle();
                cur = null;
            }
        }
    } finally {
        parent.recycle();
        if (cur != null) {
            cur.recycle();
        }
    }
    return null;
}
 
Example 6
Source File: TextEventInterpreter.java    From talkback with Apache License 2.0 5 votes vote down vote up
protected boolean sourceEqualsLastNode(AccessibilityEvent event) {
  AccessibilityNodeInfo source = null;
  try {
    source = event.getSource();
    AccessibilityNodeInfo lastNode = mHistory.getLastNode();
    return (source != null) && lastNode != null && source.equals(lastNode);
  } finally {
    AccessibilityNodeInfoUtils.recycleNodes(source);
  }
}