Example usage for android.view.accessibility AccessibilityNodeInfo obtain

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

Introduction

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

Prototype

public static AccessibilityNodeInfo obtain(AccessibilityNodeInfo info) 

Source Link

Document

Returns a cached instance if such is available or a new one is create.

Usage

From source file:com.android.switchaccess.test.ShadowAccessibilityNodeInfoCompat.java

@Implementation
public static AccessibilityNodeInfoCompat obtain(AccessibilityNodeInfoCompat compat) {
    final AccessibilityNodeInfo newInfo = AccessibilityNodeInfo
            .obtain((AccessibilityNodeInfo) compat.getInfo());
    return new AccessibilityNodeInfoCompat(newInfo);
}

From source file:com.android.screenspeak.SavedNode.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOWS_CHANGED:
        clearCache();//from w  ww  . jav  a2 s .  c o m
        break;
    case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
        AccessibilityNodeInfo source = event.getSource();
        if (source != null) {
            AccessibilityNodeInfoCompat copyNode = new AccessibilityNodeInfoCompat(
                    AccessibilityNodeInfo.obtain(source));
            Selection selection = new Selection(event.getFromIndex(), event.getToIndex());
            mSelectionCache.put(copyNode, selection);
        }
        break;
    }
}

From source file:com.android.switchaccess.SwitchAccessNodeCompat.java

/**
 * Obtain a new copy of this object. The resulting node must be recycled for efficient use
 * of underlying resources.//w w  w. ja va  2 s .co m
 *
 * @return A new copy of the node
 */
public SwitchAccessNodeCompat obtainCopy() {
    SwitchAccessNodeCompat obtainedInstance = new SwitchAccessNodeCompat(
            AccessibilityNodeInfo.obtain((AccessibilityNodeInfo) getInfo()), mWindowsAbove);

    /* Preserve lazily-initialized value if we have it */
    if (mVisibilityCalculated) {
        obtainedInstance.mVisibilityCalculated = true;
        obtainedInstance.mVisibleBoundsInScreen = new Rect(mVisibleBoundsInScreen);
    }

    obtainedInstance.mBoundsDuplicateAncestor = mBoundsDuplicateAncestor;
    return obtainedInstance;
}

From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java

@Override
public AccessibilityNodeInfo getRootInActiveWindow() {
    if (mIsRootNodeDirty || mRootNode == null) {
        mRootNode = super.getRootInActiveWindow();
        mIsRootNodeDirty = false;/*from w ww.  ja  v  a2s  . co  m*/
    }
    return mRootNode == null ? null : AccessibilityNodeInfo.obtain(mRootNode);
}

From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java

/**
 * Outputs the node tree from the current node using dfs preorder
 * traversal./*from w ww  . j  a v a  2s .  c  om*/
 */
private void printNodes() {
    HashSet<AccessibilityNodeInfo> seen = new HashSet<AccessibilityNodeInfo>();
    if (mCurrentNode == null) {
        LogUtils.log(this, Log.VERBOSE, "No current node");
        return;
    }
    LogUtils.log(this, Log.VERBOSE, "Printing nodes");
    printNodeTree(AccessibilityNodeInfo.obtain(mCurrentNode), "", seen);
    for (AccessibilityNodeInfo node : seen) {
        node.recycle();
    }
}