Example usage for android.view.accessibility AccessibilityEvent setFromIndex

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

Introduction

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

Prototype

public void setFromIndex(int fromIndex) 

Source Link

Document

Sets the index of the first character of the changed sequence or the beginning of a text selection or the index of the first visible item when scrolling.

Usage

From source file:com.android.datetimepicker.date.YearPickerView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        AccessibilityEventCompat.asRecord(event).setToIndex(0);
    }/*ww w  . ja va2  s .  c o m*/
}

From source file:com.codetroopers.betterpickers.calendardatepicker.YearPickerView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);// w  w  w.j  a  va 2 s.c o m
    }
}

From source file:com.redinput.datetimepickercompat.date.YearPickerView.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   w w  w  .  ja v  a 2 s.  c om
        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.
            if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
                event.setFromIndex(0);
            }
        }

    });
}

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  ww  .  j  a va2  s . c o  m
    event.setCurrentItemIndex(getSelectedItemPosition());
    event.setFromIndex(getFirstVisiblePosition());
    event.setToIndex(getLastVisiblePosition());
    event.setItemCount(getCount());
}

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

/**
 * Resets the focused task.//from ww w. jav a2 s. 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.android.launcher2.PagedView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setScrollable(true);//from  w w w .ja v  a2 s  .  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);

        final int action;
        if (getNextPage() >= mCurrentPage) {
            action = AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
        } else {/*from   w  ww. j  a  v  a2  s  .  com*/
            action = AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
        }

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

From source file:com.android.internal.widget.ViewPager.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);

    event.setClassName(ViewPager.class.getName());
    event.setScrollable(canScroll());//w w w  .ja va2  s .co m

    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED && mAdapter != null) {
        event.setItemCount(mAdapter.getCount());
        event.setFromIndex(mCurItem);
        event.setToIndex(mCurItem);
    }
}