Example usage for android.support.v4.view ViewCompat onInitializeAccessibilityNodeInfo

List of usage examples for android.support.v4.view ViewCompat onInitializeAccessibilityNodeInfo

Introduction

In this page you can find the example usage for android.support.v4.view ViewCompat onInitializeAccessibilityNodeInfo.

Prototype

public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) 

Source Link

Document

Initializes an android.view.accessibility.AccessibilityNodeInfo with information about this view.

Usage

From source file:com.googlecode.eyesfree.utils.ExploreByTouchHelper.java

/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * parent view populated with its virtual descendants.
 *
 * @return An {@link AccessibilityNodeInfoCompat} for the parent view.
 *//*w w  w  .  j  av a2 s .  co m*/
private AccessibilityNodeInfoCompat getNodeForHost() {
    // Since we don't want the parent to be focusable, but we can't remove
    // actions from a node, copy over the necessary fields.
    final AccessibilityNodeInfoCompat result = AccessibilityNodeInfoCompat.obtain(mHost);
    final AccessibilityNodeInfoCompat source = AccessibilityNodeInfoCompat.obtain(mHost);
    ViewCompat.onInitializeAccessibilityNodeInfo(mHost, source);

    // Copy over parent and screen bounds.
    source.getBoundsInParent(mTempParentRect);
    source.getBoundsInScreen(mTempScreenRect);
    result.setBoundsInParent(mTempParentRect);
    result.setBoundsInScreen(mTempScreenRect);

    // Set up the parent view, if applicable.
    final ViewParent parent = mHost.getParent();
    if (parent instanceof View) {
        result.setParent((View) parent);
    }

    // Populate the minimum required fields.
    result.setVisibleToUser(source.isVisibleToUser());
    result.setPackageName(source.getPackageName());
    result.setClassName(source.getClassName());

    // Add the fake root node.
    result.addChild(mHost, ROOT_ID);

    return result;
}

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

/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * parent view populated with its virtual descendants.
 *
 * @return An {@link AccessibilityNodeInfoCompat} for the parent view.
 *//*w w  w.  j ava 2s . c  o  m*/
private AccessibilityNodeInfoCompat getNodeForRoot() {
    // The root node is identical to the parent node, except that it is a
    // child of the parent view and is populated with virtual descendants.
    final AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain(mHost);
    ViewCompat.onInitializeAccessibilityNodeInfo(mHost, node);

    // Add the virtual descendants.
    final LinkedList<Integer> virtualViewIds = new LinkedList<>();
    getVisibleVirtualViewIds(virtualViewIds);

    for (Integer virtualViewId : virtualViewIds) {
        node.addChild(mHost, virtualViewId);
    }

    // Set up the node as a child of the parent.
    node.setParent(mHost);
    node.setSource(mHost, ROOT_ID);

    return node;
}

From source file:com.googlecode.eyesfree.utils.ExploreByTouchHelper.java

/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * parent view populated with its virtual descendants.
 *
 * @return An {@link AccessibilityNodeInfoCompat} for the parent view.
 *///from  w ww  .  j a va  2 s  .c  o m
private AccessibilityNodeInfoCompat getNodeForRoot() {
    // The root node is identical to the parent node, except that it is a
    // child of the parent view and is populated with virtual descendants.
    final AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain(mHost);
    ViewCompat.onInitializeAccessibilityNodeInfo(mHost, node);

    // Add the virtual descendants.
    final LinkedList<Integer> virtualViewIds = new LinkedList<Integer>();
    getVisibleVirtualViewIds(virtualViewIds);

    for (Integer virtualViewId : virtualViewIds) {
        node.addChild(mHost, virtualViewId);
    }

    // Set up the node as a child of the parent.
    node.setParent(mHost);
    node.setSource(mHost, ROOT_ID);

    return node;
}