Java 类android.view.accessibility.AccessibilityNodeInfo.CollectionInfo 实例源码

项目:talkback    文件:CollectionStateTest.java   
private AccessibilityNodeInfo createList(String name,
        int numItems,
        int headingIndex,
        List<AccessibilityNodeInfo> items) {
    AccessibilityNodeInfo list = AccessibilityNodeInfo.obtain();
    list.setContentDescription(name);
    list.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(numItems, 1, false));

    ShadowAccessibilityNodeInfo shadow = getShadow(list);
    for (int i = 0; i < numItems; ++i) {
        AccessibilityNodeInfo item = AccessibilityNodeInfo.obtain();
        item.setContentDescription("Item " + i);
        item.setCollectionItemInfo(AccessibilityNodeInfo.CollectionItemInfo.obtain(i, 1, 1, 1,
                i == headingIndex));

        shadow.addChild(item);
        items.add(item);
    }

    return list;
}
项目:talkback    文件:CollectionStateTest.java   
private AccessibilityNodeInfo createGrid(String name, int rows, int cols) {
    AccessibilityNodeInfo grid = AccessibilityNodeInfo.obtain();
    grid.setContentDescription(name);
    grid.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(rows, cols, false));

    return grid;
}
项目:boohee_v5.6    文件:AccessibilityNodeInfoCompatApi21.java   
public static Object obtainCollectionInfo(int rowCount, int columnCount, boolean hierarchical, int selectionMode) {
    return CollectionInfo.obtain(rowCount, columnCount, hierarchical, selectionMode);
}
项目:FMTech    文件:AccessibilityNodeInfoCompat.java   
public final Object obtainCollectionInfo(int paramInt1, int paramInt2, boolean paramBoolean, int paramInt3)
{
  return AccessibilityNodeInfo.CollectionInfo.obtain(paramInt1, paramInt2, false, 0);
}
项目:FMTech    文件:AccessibilityNodeInfoCompat.java   
public Object obtainCollectionInfo(int paramInt1, int paramInt2, boolean paramBoolean, int paramInt3)
{
  return AccessibilityNodeInfo.CollectionInfo.obtain(paramInt1, paramInt2, false);
}
项目:FMTech    文件:AccessibilityNodeInfoCompat.java   
public final void setCollectionInfo(Object paramObject1, Object paramObject2)
{
  ((AccessibilityNodeInfo)paramObject1).setCollectionInfo((AccessibilityNodeInfo.CollectionInfo)paramObject2);
}
项目:talkback    文件:ShadowAccessibilityNodeInfo.java   
@Implementation
public CollectionInfo getCollectionInfo() {
    return collectionInfo;
}
项目:talkback    文件:ShadowAccessibilityNodeInfo.java   
@Implementation
public void setCollectionInfo(CollectionInfo collectionInfo) {
    this.collectionInfo = collectionInfo;
}
项目:talkback    文件:CollectionStateTest.java   
@Test
public void testNested_mostlyHierarchical() {
    AccessibilityNodeInfo root = AccessibilityNodeInfo.obtain();
    root.setClassName(WEBVIEW_CLASS_NAME);

    AccessibilityNodeInfo list1 = AccessibilityNodeInfo.obtain();
    list1.setCollectionInfo(CollectionInfo.obtain(2, 1, true /* hierarchical */));
    getShadow(root).addChild(list1);

    AccessibilityNodeInfo list2 = AccessibilityNodeInfo.obtain();
    list2.setCollectionInfo(CollectionInfo.obtain(2, 1, true  /* hierarchical */));
    list2.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list1).addChild(list2);

    AccessibilityNodeInfo list3 = AccessibilityNodeInfo.obtain();
    list3.setCollectionInfo(CollectionInfo.obtain(2, 1, false  /* hierarchical */));
    list3.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list2).addChild(list3);

    AccessibilityNodeInfo item = AccessibilityNodeInfo.obtain();
    item.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list3).addChild(item);

    try {
        // list2 is inside of list1
        AccessibilityNodeInfoCompat listCompat2 = new AccessibilityNodeInfoCompat(list2);
        mCollectionState.updateCollectionInformation(listCompat2, null);
        assertEquals(0, mCollectionState.getCollectionLevel());

        // list3 is inside of list2
        AccessibilityNodeInfoCompat listCompat3 = new AccessibilityNodeInfoCompat(list3);
        mCollectionState.updateCollectionInformation(listCompat3, null);
        assertEquals(1, mCollectionState.getCollectionLevel());

        // item is inside of list3
        AccessibilityNodeInfoCompat itemCompat = new AccessibilityNodeInfoCompat(item);
        mCollectionState.updateCollectionInformation(itemCompat, null);
        assertEquals(-1, mCollectionState.getCollectionLevel()); // list3 not hierarchical!

        AccessibilityNodeInfoCompat rootCompat = new AccessibilityNodeInfoCompat(root);
        forceInternalRecycle(rootCompat);
    } finally {
        root.recycle();
        list1.recycle();
        list2.recycle();
        list3.recycle();
        item.recycle();
    }
}
项目:talkback    文件:CollectionStateTest.java   
@Test
public void testNested_mostlyNonHierarchical() {
    AccessibilityNodeInfo root = AccessibilityNodeInfo.obtain();
    root.setClassName(WEBVIEW_CLASS_NAME);

    AccessibilityNodeInfo list1 = AccessibilityNodeInfo.obtain();
    list1.setCollectionInfo(CollectionInfo.obtain(2, 1, false /* hierarchical */));
    getShadow(root).addChild(list1);

    AccessibilityNodeInfo list2 = AccessibilityNodeInfo.obtain();
    list2.setCollectionInfo(CollectionInfo.obtain(2, 1, false  /* hierarchical */));
    list2.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list1).addChild(list2);

    AccessibilityNodeInfo list3 = AccessibilityNodeInfo.obtain();
    list3.setCollectionInfo(CollectionInfo.obtain(2, 1, true  /* hierarchical */));
    list3.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list2).addChild(list3);

    AccessibilityNodeInfo item = AccessibilityNodeInfo.obtain();
    item.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list3).addChild(item);

    try {
        // list2 is inside of list1
        AccessibilityNodeInfoCompat listCompat2 = new AccessibilityNodeInfoCompat(list2);
        mCollectionState.updateCollectionInformation(listCompat2, null);
        assertEquals(-1, mCollectionState.getCollectionLevel()); // list1 not hierarchical!

        // list3 is inside of list2
        AccessibilityNodeInfoCompat listCompat3 = new AccessibilityNodeInfoCompat(list3);
        mCollectionState.updateCollectionInformation(listCompat3, null);
        assertEquals(-1, mCollectionState.getCollectionLevel()); // list2 not hierarchical!

        // item is inside of list3
        AccessibilityNodeInfoCompat itemCompat = new AccessibilityNodeInfoCompat(item);
        mCollectionState.updateCollectionInformation(itemCompat, null);
        assertEquals(0, mCollectionState.getCollectionLevel());

        AccessibilityNodeInfoCompat rootCompat = new AccessibilityNodeInfoCompat(root);
        forceInternalRecycle(rootCompat);
    } finally {
        root.recycle();
        list1.recycle();
        list2.recycle();
        list3.recycle();
        item.recycle();
    }
}