Java Code Examples for android.view.accessibility.AccessibilityEvent#getScrollDeltaY()

The following examples show how to use android.view.accessibility.AccessibilityEvent#getScrollDeltaY() . 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: ScrollEventInterpreter.java    From talkback with Apache License 2.0 5 votes vote down vote up
@TargetApi(BuildVersionUtils.API_R)
@SearchDirectionOrUnknown
private int getScrollDirectionFromDeltas(AccessibilityEvent event) {
  int scrollDeltaX = event.getScrollDeltaX();
  int scrollDeltaY = event.getScrollDeltaY();
  if (scrollDeltaX == DELTA_UNDEFINED && scrollDeltaY == DELTA_UNDEFINED) {
    return TraversalStrategy.SEARCH_FOCUS_UNKNOWN;
  }
  if (scrollDeltaX > 0 || scrollDeltaY > 0) {
    return TraversalStrategy.SEARCH_FOCUS_FORWARD;
  } else if (scrollDeltaX < 0 || scrollDeltaY < 0) {
    return TraversalStrategy.SEARCH_FOCUS_BACKWARD;
  }
  return TraversalStrategy.SEARCH_FOCUS_UNKNOWN;
}
 
Example 2
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 4 votes vote down vote up
public static int getScrollDeltaY(AccessibilityEvent event) {
  return BuildVersionUtils.isAtLeastP() ? event.getScrollDeltaY() : DELTA_UNDEFINED;
}
 
Example 3
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 4 votes vote down vote up
public static boolean hasValidScrollDelta(AccessibilityEvent event) {
  return BuildVersionUtils.isAtLeastP()
      && ((event.getScrollDeltaX() != DELTA_UNDEFINED)
          || (event.getScrollDeltaY() != DELTA_UNDEFINED));
}