List of usage examples for android.support.v4.view.accessibility AccessibilityRecordCompat getItemCount
public int getItemCount()
From source file:com.android.screenspeak.eventprocessor.ProcessorFocusAndSingleTap.java
/** * @param record the AccessbilityRecord for the event * @param isViewFocusedEvent true if the event is TYPE_VIEW_FOCUSED, otherwise it is * TYPE_VIEW_SELECTED./* w w w . j a v a 2 s .c o m*/ */ private boolean setFocusOnView(AccessibilityRecordCompat record, boolean isViewFocusedEvent) { AccessibilityNodeInfoCompat source = null; AccessibilityNodeInfoCompat existing = null; AccessibilityNodeInfoCompat child = null; try { source = record.getSource(); if (source == null) { return false; } if (record.getItemCount() > 0) { final int index = (record.getCurrentItemIndex() - record.getFromIndex()); if (index >= 0 && index < source.getChildCount()) { child = source.getChild(index); if (child != null) { if (AccessibilityNodeInfoUtils.isTopLevelScrollItem(child) && tryFocusing(child)) { return true; } } } } if (!isViewFocusedEvent) { return false; } // Logic below is only specific to TYPE_VIEW_FOCUSED event // Try focusing the source node. if (tryFocusing(source)) { return true; } // If we fail and the source node already contains focus, abort. existing = source.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (existing != null) { return false; } // If we fail to focus a node, perhaps because it is a focusable // but non-speaking container, we should still attempt to place // focus on a speaking child within the container. child = AccessibilityNodeInfoUtils.searchFromBfs(source, AccessibilityNodeInfoUtils.FILTER_SHOULD_FOCUS); return child != null && tryFocusing(child); } finally { AccessibilityNodeInfoUtils.recycleNodes(source, existing, child); } }