/** * Called by the accessibility delegate to initialize an accessibility event. * <p> * Default implementation adds item count and scroll information to the event. * * @param recycler The Recycler that can be used to convert view positions into adapter * positions * @param state The current state of RecyclerView * @param event The event instance to initialize * @see View#onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent) */ public void onInitializeAccessibilityEvent(Recycler recycler, State state, AccessibilityEvent event) { final AccessibilityRecord record = event.getRecord(0); if (mRecyclerView == null || record == null) { return; } record.setScrollable(mRecyclerView.canScrollVertically(1) || mRecyclerView.canScrollVertically(-1) || mRecyclerView.canScrollHorizontally(-1) || mRecyclerView.canScrollHorizontally(1)); if (mRecyclerView.mAdapter != null) { record.setItemCount(mRecyclerView.mAdapter.getItemCount()); } }
public static SubjectFactory<AccessibilityRecordSubject, AccessibilityRecord> type() { return new SubjectFactory<AccessibilityRecordSubject, AccessibilityRecord>() { @Override public AccessibilityRecordSubject getSubject(FailureStrategy fs, AccessibilityRecord that) { return new AccessibilityRecordSubject(fs, that); } }; }
@Override public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { super.onInitializeAccessibilityEvent( host, event ); event.setClassName( SdkCenteredViewPager.class.getName() ); final AccessibilityRecord recordCompat = AccessibilityRecord.obtain(); recordCompat.setScrollable( canScroll() ); if ( event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED && mAdapter != null ) { recordCompat.setItemCount( mAdapter.getCount() ); recordCompat.setFromIndex( mCurItem ); recordCompat.setToIndex( mCurItem ); } }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); if (getChildCount() > 0) { final AccessibilityRecord record = event.getRecord(0); record.setFromIndex(findFirstVisibleItemPosition()); record.setToIndex(findLastVisibleItemPosition()); } }
public static Object obtain() { return AccessibilityRecord.obtain(); }
public static Object obtain(Object record) { return AccessibilityRecord.obtain((AccessibilityRecord) record); }
public static int getAddedCount(Object record) { return ((AccessibilityRecord) record).getAddedCount(); }
public static CharSequence getBeforeText(Object record) { return ((AccessibilityRecord) record).getBeforeText(); }
public static CharSequence getClassName(Object record) { return ((AccessibilityRecord) record).getClassName(); }
public static CharSequence getContentDescription(Object record) { return ((AccessibilityRecord) record).getContentDescription(); }
public static int getCurrentItemIndex(Object record) { return ((AccessibilityRecord) record).getCurrentItemIndex(); }
public static int getFromIndex(Object record) { return ((AccessibilityRecord) record).getFromIndex(); }
public static int getItemCount(Object record) { return ((AccessibilityRecord) record).getItemCount(); }
public static Parcelable getParcelableData(Object record) { return ((AccessibilityRecord) record).getParcelableData(); }
public static int getRemovedCount(Object record) { return ((AccessibilityRecord) record).getRemovedCount(); }
public static int getScrollX(Object record) { return ((AccessibilityRecord) record).getScrollX(); }
public static int getScrollY(Object record) { return ((AccessibilityRecord) record).getScrollY(); }
public static Object getSource(Object record) { return ((AccessibilityRecord) record).getSource(); }
public static List<CharSequence> getText(Object record) { return ((AccessibilityRecord) record).getText(); }
public static int getToIndex(Object record) { return ((AccessibilityRecord) record).getToIndex(); }
public static int getWindowId(Object record) { return ((AccessibilityRecord) record).getWindowId(); }
public static boolean isChecked(Object record) { return ((AccessibilityRecord) record).isChecked(); }
public static boolean isEnabled(Object record) { return ((AccessibilityRecord) record).isEnabled(); }
public static boolean isFullScreen(Object record) { return ((AccessibilityRecord) record).isFullScreen(); }
public static boolean isPassword(Object record) { return ((AccessibilityRecord) record).isPassword(); }
public static boolean isScrollable(Object record) { return ((AccessibilityRecord) record).isScrollable(); }
public static void recycle(Object record) { ((AccessibilityRecord) record).recycle(); }
public static void setAddedCount(Object record, int addedCount) { ((AccessibilityRecord) record).setAddedCount(addedCount); }
public static void setBeforeText(Object record, CharSequence beforeText) { ((AccessibilityRecord) record).setBeforeText(beforeText); }
public static void setChecked(Object record, boolean isChecked) { ((AccessibilityRecord) record).setChecked(isChecked); }
public static void setClassName(Object record, CharSequence className) { ((AccessibilityRecord) record).setClassName(className); }
public static void setContentDescription(Object record, CharSequence contentDescription) { ((AccessibilityRecord) record).setContentDescription(contentDescription); }
public static void setCurrentItemIndex(Object record, int currentItemIndex) { ((AccessibilityRecord) record).setCurrentItemIndex(currentItemIndex); }
public static void setEnabled(Object record, boolean isEnabled) { ((AccessibilityRecord) record).setEnabled(isEnabled); }
public static void setFromIndex(Object record, int fromIndex) { ((AccessibilityRecord) record).setFromIndex(fromIndex); }
public static void setFullScreen(Object record, boolean isFullScreen) { ((AccessibilityRecord) record).setFullScreen(isFullScreen); }
public static void setItemCount(Object record, int itemCount) { ((AccessibilityRecord) record).setItemCount(itemCount); }
public static void setParcelableData(Object record, Parcelable parcelableData) { ((AccessibilityRecord) record).setParcelableData(parcelableData); }
public static void setPassword(Object record, boolean isPassword) { ((AccessibilityRecord) record).setPassword(isPassword); }