Example usage for android.view.accessibility AccessibilityNodeInfo getWindow

List of usage examples for android.view.accessibility AccessibilityNodeInfo getWindow

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityNodeInfo getWindow.

Prototype

public AccessibilityWindowInfo getWindow() 

Source Link

Document

Gets the window to which this node belongs.

Usage

From source file:com.android.utils.AccessibilityNodeInfoUtils.java

/**
 * Returns the node to which the given node's window is anchored, if there is an anchor.
 * Note: you must recycle the node that is returned from this method.
 *///  w  w  w. ja  va2  s  . c o  m
public static AccessibilityNodeInfoCompat getAnchor(@Nullable AccessibilityNodeInfoCompat node) {
    if (!BuildCompat.isAtLeastN()) {
        return null;
    }

    if (node == null) {
        return null;
    }

    AccessibilityNodeInfo nativeNode = (AccessibilityNodeInfo) node.getInfo();
    if (nativeNode == null) {
        return null;
    }

    AccessibilityWindowInfo nativeWindow = nativeNode.getWindow();
    if (nativeWindow == null) {
        return null;
    }

    AccessibilityNodeInfo nativeAnchor = nativeWindow.getAnchor();
    if (nativeAnchor == null) {
        return null;
    }

    return new AccessibilityNodeInfoCompat(nativeAnchor);
}