Java Code Examples for android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#isScrollable()

The following examples show how to use android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#isScrollable() . 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: AccessibilityNodeInfoUtils.java    From brailleback with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether a given node is scrollable.
 *
 * @param node The node to examine.
 * @return {@code true} if the node is scrollable.
 */
private static boolean isScrollable(AccessibilityNodeInfoCompat node) {
    if (node.isScrollable()) {
        return true;
    }

    return supportsAnyAction(node,
            AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD,
            AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
}
 
Example 2
Source File: AccessibilityUtil.java    From stetho with MIT License 5 votes vote down vote up
/**
 * Determines whether the provided {@link View} and {@link AccessibilityNodeInfoCompat} is a
 * top-level item in a scrollable container.
 *
 * @param view The {@link View} to evaluate
 * @param node The {@link AccessibilityNodeInfoCompat} to evaluate
 * @return {@code true} if it is a top-level item in a scrollable container.
 */
public static boolean isTopLevelScrollItem(
    @Nullable AccessibilityNodeInfoCompat node,
    @Nullable View view) {
  if (node == null || view == null) {
    return false;
  }

  View parent = (View) ViewCompat.getParentForAccessibility(view);
  if (parent == null) {
    return false;
  }

  if (node.isScrollable()) {
    return true;
  }

  List actionList = node.getActionList();
  if (actionList.contains(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) ||
      actionList.contains(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD)) {
    return true;
  }

  // AdapterView, ScrollView, and HorizontalScrollView are focusable
  // containers, but Spinner is a special case.
  if (parent instanceof Spinner) {
    return false;
  }

  return
      parent instanceof AdapterView ||
          parent instanceof ScrollView ||
          parent instanceof HorizontalScrollView;
}