Java Code Examples for androidx.core.view.accessibility.AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getColumnIndex()

The following examples show how to use androidx.core.view.accessibility.AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getColumnIndex() . 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: NodeDescription.java    From talkback with Apache License 2.0 6 votes vote down vote up
public boolean indexMatches(AccessibilityNodeInfoCompat node) {
  if (node == null) {
    return false;
  }
  if (indexType == INDEX_TYPE_COLLECTION) {
    CollectionItemInfoCompat itemInfo = node.getCollectionItemInfo();
    return (itemInfo != null)
        && (itemInfo.getRowIndex() == rowIndex)
        && (itemInfo.getColumnIndex() == columnIndex);
  } else {
    AccessibilityNodeInfoCompat parent = null;
    AccessibilityNodeInfoCompat child = null;
    try {
      parent = node.getParent();
      if (parent == null || parent.getChildCount() <= rawIndexInParent) {
        return false;
      }
      child = parent.getChild(rawIndexInParent);
      return node.equals(child);

    } finally {
      AccessibilityNodeInfoUtils.recycleNodes(parent, child);
    }
  }
}
 
Example 2
Source File: CollectionState.java    From talkback with Apache License 2.0 5 votes vote down vote up
/**
 * @return -1 if there is no valid column index for the item; otherwise the item's column index
 */
private static int getColumnIndex(
    @NonNull CollectionItemInfoCompat item, @NonNull CollectionInfoCompat collection) {
  if (item.getColumnSpan() == collection.getColumnCount()) {
    return -1;
  } else if (item.getColumnIndex() < 0) {
    return -1;
  } else {
    return item.getColumnIndex();
  }
}
 
Example 3
Source File: NodeDescription.java    From talkback with Apache License 2.0 5 votes vote down vote up
static NodeDescription obtain(AccessibilityNodeInfoCompat node) {
  CollectionItemInfoCompat itemInfo = node.getCollectionItemInfo();
  return new NodeDescription(
      node.getClassName(),
      node.getViewIdResourceName(),
      itemInfo == null ? INDEX_TYPE_RAW : INDEX_TYPE_COLLECTION,
      itemInfo == null ? UNDEFINED_INDEX : itemInfo.getRowIndex(),
      itemInfo == null ? UNDEFINED_INDEX : itemInfo.getColumnIndex(),
      getRawIndexInParent(node),
      node.hashCode());
}