android.support.v4.view.accessibility.AccessibilityRecordCompat Java Examples

The following examples show how to use android.support.v4.view.accessibility.AccessibilityRecordCompat. 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: ExploreByTouchHelper.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityEvent} populated with
 * information about the specified item.
 *
 * @param virtualViewId The virtual view id for the item for which to
 *            construct an event.
 * @param eventType The type of event to construct.
 * @return An {@link AccessibilityEvent} populated with information about
 *         the specified item.
 */
private AccessibilityEvent createEventForChild(int virtualViewId, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setEnabled(true);
    event.setClassName(DEFAULT_CLASS_NAME);

    // Allow the client to populate the event.
    onPopulateEventForVirtualView(virtualViewId, event);

    // Make sure the developer is following the rules.
    if (event.getText().isEmpty() && (event.getContentDescription() == null)) {
        throw new RuntimeException("Callbacks must add text or a content description in "
                + "populateEventForVirtualViewId()");
    }

    // Don't allow the client to override these properties.
    event.setPackageName(mView.getContext().getPackageName());

    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mView, virtualViewId);

    return event;
}
 
Example #2
Source File: ExploreByTouchHelper.java    From brailleback with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityEvent} populated with
 * information about the specified item.
 *
 * @param virtualViewId The virtual view id for the item for which to
 *            construct an event.
 * @param eventType The type of event to construct.
 * @return An {@link AccessibilityEvent} populated with information about
 *         the specified item.
 */
private AccessibilityEvent getEventForVirtualViewId(int virtualViewId, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);

    // Ensure the client has good defaults.
    event.setEnabled(true);
    event.setClassName(mHost.getClass().getName() + DEFAULT_CLASS_NAME);

    // Allow the client to populate the event.
    populateEventForVirtualViewId(virtualViewId, 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.setPackageName(mHost.getContext().getPackageName());

    // Virtual view hierarchies are only supported in API 16+.
    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    record.setSource(mHost, virtualViewId);

    return event;
}
 
Example #3
Source File: ExploreByTouchHelper.java    From guideshow with MIT License 6 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityEvent} populated with
 * information about the specified item.
 *
 * @param virtualViewId The virtual view id for the item for which to
 *            construct an event.
 * @param eventType The type of event to construct.
 * @return An {@link AccessibilityEvent} populated with information about
 *         the specified item.
 */
private AccessibilityEvent createEventForChild(int virtualViewId, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setEnabled(true);
    event.setClassName(DEFAULT_CLASS_NAME);

    // Allow the client to populate the event.
    onPopulateEventForVirtualView(virtualViewId, event);

    // Make sure the developer is following the rules.
    if (event.getText().isEmpty() && (event.getContentDescription() == null)) {
        throw new RuntimeException("Callbacks must add text or a content description in "
                + "populateEventForVirtualViewId()");
    }

    // Don't allow the client to override these properties.
    event.setPackageName(mView.getContext().getPackageName());

    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mView, virtualViewId);

    return event;
}
 
Example #4
Source File: DirectionalViewpager.java    From fangzhuishushenqi with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(DirectionalViewpager.class.getName());
    AccessibilityRecordCompat recordCompat = null;
    if (isHorizontal()) {
        recordCompat =
                AccessibilityEventCompat.asRecord(event);
    } else {
        recordCompat = AccessibilityRecordCompat.obtain();
    }
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #5
Source File: StaggeredGridLayoutManager.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (getChildCount() > 0) {
        final AccessibilityRecordCompat record = AccessibilityEventCompat
                .asRecord(event);
        final View start = findFirstVisibleItemClosestToStart(false);
        final View end = findFirstVisibleItemClosestToEnd(false);
        if (start == null || end == null) {
            return;
        }
        final int startPos = getPosition(start);
        final int endPos = getPosition(end);
        if (startPos < endPos) {
            record.setFromIndex(startPos);
            record.setToIndex(endPos);
        } else {
            record.setFromIndex(endPos);
            record.setToIndex(startPos);
        }
    }
}
 
Example #6
Source File: ExploreByTouchHelper.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityEvent} populated with
 * information about the specified item.
 *
 * @param virtualViewId The virtual view id for the item for which to
 *            construct an event.
 * @param eventType The type of event to construct.
 * @return An {@link AccessibilityEvent} populated with information about
 *         the specified item.
 */
private AccessibilityEvent createEventForChild(int virtualViewId, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setEnabled(true);
    event.setClassName(DEFAULT_CLASS_NAME);

    // Allow the client to populate the event.
    onPopulateEventForVirtualView(virtualViewId, event);

    // Make sure the developer is following the rules.
    if (event.getText().isEmpty() && (event.getContentDescription() == null)) {
        throw new RuntimeException("Callbacks must add text or a content description in "
                + "populateEventForVirtualViewId()");
    }

    // Don't allow the client to override these properties.
    event.setPackageName(mView.getContext().getPackageName());

    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mView, virtualViewId);

    return event;
}
 
Example #7
Source File: AccessibilityUtils.java    From SublimePicker with Apache License 2.0 6 votes vote down vote up
public static void makeAnnouncement(View view, CharSequence announcement) {
    if (view == null)
        return;
    if (SUtils.isApi_16_OrHigher()) {
        view.announceForAccessibility(announcement);
    } else {
        // For API 15 and earlier, we need to construct an accessibility event
        Context ctx = view.getContext();
        AccessibilityManager am = (AccessibilityManager) ctx.getSystemService(
                Context.ACCESSIBILITY_SERVICE);
        if (!am.isEnabled()) return;

        AccessibilityEvent event = AccessibilityEvent.obtain(
                AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
        AccessibilityRecordCompat arc = AccessibilityEventCompat.asRecord(event);
        arc.setSource(view);
        event.setClassName(view.getClass().getName());
        event.setPackageName(view.getContext().getPackageName());
        event.setEnabled(view.isEnabled());
        event.getText().add(announcement);
        am.sendAccessibilityEvent(event);
    }
}
 
Example #8
Source File: StaggeredGridLayoutManager.java    From letv with Apache License 2.0 6 votes vote down vote up
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (getChildCount() > 0) {
        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        View start = findFirstVisibleItemClosestToStart(false, true);
        View end = findFirstVisibleItemClosestToEnd(false, true);
        if (start != null && end != null) {
            int startPos = getPosition(start);
            int endPos = getPosition(end);
            if (startPos < endPos) {
                record.setFromIndex(startPos);
                record.setToIndex(endPos);
                return;
            }
            record.setFromIndex(endPos);
            record.setToIndex(startPos);
        }
    }
}
 
Example #9
Source File: TouchExplorationHelper.java    From DateTimepicker with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #10
Source File: ExploreByTouchHelper.java    From android-recipes-app with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityEvent} populated with
 * information about the specified item.
 *
 * @param virtualViewId The virtual view id for the item for which to
 *            construct an event.
 * @param eventType The type of event to construct.
 * @return An {@link AccessibilityEvent} populated with information about
 *         the specified item.
 */
private AccessibilityEvent createEventForChild(int virtualViewId, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setEnabled(true);
    event.setClassName(DEFAULT_CLASS_NAME);

    // Allow the client to populate the event.
    onPopulateEventForVirtualView(virtualViewId, event);

    // Make sure the developer is following the rules.
    if (event.getText().isEmpty() && (event.getContentDescription() == null)) {
        throw new RuntimeException("Callbacks must add text or a content description in "
                + "populateEventForVirtualViewId()");
    }

    // Don't allow the client to override these properties.
    event.setPackageName(mView.getContext().getPackageName());

    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mView, virtualViewId);

    return event;
}
 
Example #11
Source File: DirectionalViewpager.java    From ankihelper with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(DirectionalViewpager.class.getName());
    AccessibilityRecordCompat recordCompat = null;
    if (isHorizontal()) {
        recordCompat =
                AccessibilityEventCompat.asRecord(event);
    } else {
        recordCompat = AccessibilityRecordCompat.obtain();
    }
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #12
Source File: DirectionalViewpager.java    From BookReader with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(DirectionalViewpager.class.getName());
    AccessibilityRecordCompat recordCompat = null;
    if (isHorizontal()) {
        recordCompat =
                AccessibilityEventCompat.asRecord(event);
    } else {
        recordCompat = AccessibilityRecordCompat.obtain();
    }
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #13
Source File: ViewPager.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #14
Source File: ViewPager.java    From guideshow with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #15
Source File: ViewPagerEx.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPagerEx.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #16
Source File: ViewPager.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #17
Source File: ViewPager.java    From android-movies-demo with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #18
Source File: ViewPager.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #19
Source File: LinearLayoutManager.java    From Mupdf with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (getChildCount() > 0) {
        final AccessibilityRecordCompat record = AccessibilityEventCompat
                .asRecord(event);
        record.setFromIndex(findFirstVisibleItemPosition());
        record.setToIndex(findLastVisibleItemPosition());
    }
}
 
Example #20
Source File: ViewPagerEx.java    From AndroidImageSlider with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPagerEx.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #21
Source File: ViewPager.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #22
Source File: ViewPager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #23
Source File: VerticalViewPager.java    From DoubleViewPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(VerticalViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #24
Source File: NestedScrollView.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    final NestedScrollView nsvHost = (NestedScrollView) host;
    event.setClassName(ScrollView.class.getName());
    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    final boolean scrollable = nsvHost.getScrollRange() > 0;
    record.setScrollable(scrollable);
    record.setScrollX(nsvHost.getScrollX());
    record.setScrollY(nsvHost.getScrollY());
    record.setMaxScrollX(nsvHost.getScrollX());
    record.setMaxScrollY(nsvHost.getScrollRange());
}
 
Example #25
Source File: VerticalViewPager.java    From TLint with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #26
Source File: VerticalViewPager.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(VerticalViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #27
Source File: LinkagePager.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(LinkagePager.class.getName());
    final AccessibilityRecordCompat recordCompat =
            AccessibilityEventCompat.asRecord(event);
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #28
Source File: ViewPager.java    From AppCompat-Extension-Library with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example #29
Source File: ChatLinearLayoutManager.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (getChildCount() > 0) {
        final AccessibilityRecordCompat record = AccessibilityEventCompat
                .asRecord(event);
        record.setFromIndex(findFirstVisibleItemPosition());
        record.setToIndex(findLastVisibleItemPosition());
    }
}
 
Example #30
Source File: VerticalViewPager.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}