Example usage for android.view.accessibility AccessibilityEvent setItemCount

List of usage examples for android.view.accessibility AccessibilityEvent setItemCount

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityEvent setItemCount.

Prototype

public void setItemCount(int itemCount) 

Source Link

Document

Sets the number of items that can be visited.

Usage

From source file:org.chromium.chrome.browser.widget.ToolbarProgressBar.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setCurrentItemIndex((int) (mTargetProgress * 100));
    event.setItemCount(100);
}

From source file:com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setItemCount(-1);
}

From source file:com.redinput.datetimepickercompat.date.DayPickerView.java

private void installAccessibilityDelegate() {
    // The accessibility delegate enables customizing accessibility behavior
    // via composition as opposed as inheritance. The main benefit is that
    // one can write a backwards compatible application by setting the delegate
    // only if the API level is high enough i.e. the delegate is part of the APIs.
    // The easiest way to achieve that is by using the support library which
    // takes the burden of checking API version and knowing which API version
    // introduced the delegate off the developer.
    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegateCompat() {

        @Override/*from   ww w  . j  a  v  a 2s. c o m*/
        public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
            super.onInitializeAccessibilityEvent(host, event);
            // Note that View.onInitializeAccessibilityNodeInfo was introduced in
            // ICS and we would like to tweak a bit the text that is reported to
            // accessibility services via the AccessibilityNodeInfo.
            event.setItemCount(-1);
        }

        @Override
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
            super.onInitializeAccessibilityNodeInfo(host, info);
            // Note that View.onInitializeAccessibilityNodeInfo was introduced in
            // ICS and we would like to tweak a bit the text that is reported to
            // accessibility services via the AccessibilityNodeInfo.
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
        }

        @Override
        public boolean performAccessibilityAction(View host, int action, Bundle args) {
            if (action != AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD
                    && action != AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD) {
                return super.performAccessibilityAction(host, action, args);
            }

            // Figure out what month is showing.
            int firstVisiblePosition = getFirstVisiblePosition();
            int month = firstVisiblePosition % 12;
            int year = firstVisiblePosition / 12 + mController.getMinYear();
            CalendarDay day = new CalendarDay(year, month, 1);

            // Scroll either forward or backward one month.
            if (action == AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) {
                day.month++;
                if (day.month == 12) {
                    day.month = 0;
                    day.year++;
                }
            } else if (action == AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD) {
                View firstVisibleView = getChildAt(0);
                // If the view is fully visible, jump one month back. Otherwise, we'll just jump
                // to the first day of first visible month.
                if (firstVisibleView != null && firstVisibleView.getTop() >= -1) {
                    // There's an off-by-one somewhere, so the top of the first visible item
                    // will
                    // actually be -1 when it's at the exact top.
                    day.month--;
                    if (day.month == -1) {
                        day.month = 11;
                        day.year--;
                    }
                }
            }

            // Go to that month.
            Utils.tryAccessibilityAnnounce(host, getMonthAndYearString(day));
            goTo(day, true, false, true);
            mPerformingScroll = true;
            return true;
        }
    });
}

From source file:com.actionbarsherlock.internal.widget.IcsProgressBar.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setItemCount(mMax);
    event.setCurrentItemIndex(mProgress);
}

From source file:com.actionbarsherlock.internal.widget.IcsAdapterView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setScrollable(isScrollableForAccessibility());
    View selectedView = getSelectedView();
    if (selectedView != null) {
        event.setEnabled(selectedView.isEnabled());
    }/*w w  w. j  av  a  2 s .  c  om*/
    event.setCurrentItemIndex(getSelectedItemPosition());
    event.setFromIndex(getFirstVisiblePosition());
    event.setToIndex(getLastVisiblePosition());
    event.setItemCount(getCount());
}

From source file:com.albedinsky.android.ui.widget.BaseProgressBar.java

/**
 *///from  w  w  w.  j  a  v a 2 s .c o  m
@Override
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(BaseProgressBar.class.getName());
    event.setItemCount(mMax);
    event.setCurrentItemIndex(mProgress);
}

From source file:me.lizheng.deckview.views.DeckView.java

/**
 * Resets the focused task./*from w  ww .  j  a  v a  2s . com*/
 */
//    void resetFocusedTask() {
//        if ((0 <= mFocusedTaskIndex) && (mFocusedTaskIndex < mCallback.getData().size())) {
//            DeckChildView tv = getChildViewForTask(mCallback.getData().get(mFocusedTaskIndex));
//            if (tv != null) {
//                tv.unsetFocusedTask();
//            }
//        }
//        mFocusedTaskIndex = -1;
//    }

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    int childCount = getChildCount();
    if (childCount > 0) {
        @SuppressWarnings("unchecked")
        DeckChildView<T> backMostTask = (DeckChildView) getChildAt(0);
        @SuppressWarnings("unchecked")
        DeckChildView<T> frontMostTask = (DeckChildView) getChildAt(childCount - 1);
        event.setFromIndex(mCallback.getData().indexOf(backMostTask.getAttachedKey()));
        event.setToIndex(mCallback.getData().indexOf(frontMostTask.getAttachedKey()));
    }
    event.setItemCount(mCallback.getData().size());
    event.setScrollY(mStackScroller.mScroller.getCurrY());
    //        event.setMaxScrollY(mStackScroller.progressToScrollRange(mLayoutAlgorithm.mMaxScrollP));
}

From source file:com.albedinsky.android.support.ui.widget.BaseProgressBar.java

/**
 *//*from   ww  w .ja v a  2 s  . c  o  m*/
@Override
public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(BaseProgressBar.class.getName());
    event.setItemCount(mMax);
    event.setCurrentItemIndex(mProgress);
}

From source file:com.android.launcher2.PagedView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setScrollable(true);//from  w  w w.ja va  2s . c  o  m
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(mCurrentPage);
        event.setToIndex(mCurrentPage);
        event.setItemCount(getChildCount());
    }
}

From source file:cc.flydev.launcher.Page.java

private void sendScrollAccessibilityEvent() {
    AccessibilityManager am = (AccessibilityManager) getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isEnabled()) {
        AccessibilityEvent ev = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
        ev.setItemCount(getChildCount());
        ev.setFromIndex(mCurrentPage);/*from  w  w  w  .  ja  v a  2s.  c o  m*/

        final int action;
        if (getNextPage() >= mCurrentPage) {
            action = AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
        } else {
            action = AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
        }

        ev.setAction(action);
        sendAccessibilityEventUnchecked(ev);
    }
}