private AccessibilityEvent getEventForItem(T item, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    final int virtualDescendantId = getIdForItem(item);

    // Ensure the client has good defaults.
    event.setEnabled(true);

    // Allow the client to populate the event.
    populateEventForItem(item, event);

    if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) {
      throw new RuntimeException(
          "You must add text or a content description in populateEventForItem()");
    }

    // Don't allow the client to override these properties.
    event.setClassName(item.getClass().getName());
    event.setPackageName(mParentView.getContext().getPackageName());
    record.setSource(mParentView, virtualDescendantId);

    return event;
  }
Ejemplo n.º 2
0
    public void onInitializeAccessibilityEvent(View var1, AccessibilityEvent var2) {
      super.onInitializeAccessibilityEvent(var1, var2);
      NestedScrollView var4 = (NestedScrollView) var1;
      var2.setClassName(ScrollView.class.getName());
      AccessibilityRecordCompat var5 = AccessibilityEventCompat.asRecord(var2);
      boolean var3;
      if (var4.getScrollRange() > 0) {
        var3 = true;
      } else {
        var3 = false;
      }

      var5.setScrollable(var3);
      var5.setScrollX(var4.getScrollX());
      var5.setScrollY(var4.getScrollY());
      var5.setMaxScrollX(var4.getScrollX());
      var5.setMaxScrollY(var4.getScrollRange());
    }