Example usage for android.view View sendAccessibilityEvent

List of usage examples for android.view View sendAccessibilityEvent

Introduction

In this page you can find the example usage for android.view View sendAccessibilityEvent.

Prototype

public void sendAccessibilityEvent(int eventType) 

Source Link

Document

Sends an accessibility event of the given type.

Usage

From source file:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java

void dispatchOnDrawerClosed(View drawerView) {
    final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
    if ((lp.openState & LayoutParams.FLAG_IS_OPENED) == 1) {
        lp.openState = 0;/*from   w  w w .  j a v  a2s  .c om*/

        if (mListeners != null) {
            // Notify the listeners. Do that from the end of the list so that if a listener
            // removes itself as the result of being called, it won't mess up with our iteration
            int listenerCount = mListeners.size();
            for (int i = listenerCount - 1; i >= 0; i--) {
                mListeners.get(i).onDrawerClosed(drawerView);
            }
        }

        updateChildrenImportantForAccessibility(drawerView, false);

        // Only send WINDOW_STATE_CHANGE if the host has window focus. This
        // may change if support for multiple foreground windows (e.g. IME)
        // improves.
        if (hasWindowFocus()) {
            final View rootView = getRootView();
            if (rootView != null) {
                rootView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
            }
        }
    }
}

From source file:chan.android.app.bitwise.util.StaggeredGridView.java

public boolean performItemClick(View view, int position, long id) {
    if (mOnItemClickListener != null) {
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }/*  w ww  . j  a  v  a2 s  . c o  m*/
        mOnItemClickListener.onItemClick(this, view, position, id);
        return true;
    }

    return false;
}

From source file:org.chromium.chrome.browser.tab.Tab.java

/**
 * Update whether or not the current native tab and/or web contents are
 * currently visible (from an accessibility perspective), or whether
 * they're obscured by another view.//from   w  w  w . j ava2s.  c  om
 */
public void updateAccessibilityVisibility() {
    View view = getView();
    if (view != null) {
        int importantForAccessibility = isObscuredByAnotherViewForAccessibility()
                ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                : View.IMPORTANT_FOR_ACCESSIBILITY_YES;
        if (view.getImportantForAccessibility() != importantForAccessibility) {
            view.setImportantForAccessibility(importantForAccessibility);
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
        }
    }

    ContentViewCore cvc = getContentViewCore();
    if (cvc != null) {
        boolean isWebContentObscured = isObscuredByAnotherViewForAccessibility() || isShowingSadTab();
        cvc.setObscuredByAnotherView(isWebContentObscured);
    }
}

From source file:com.hippo.widget.recyclerview.EasyRecyclerView.java

private boolean performItemClick(View view, int position, long id) {
    boolean handled = false;
    boolean dispatchItemClick = true;

    if (mChoiceMode != CHOICE_MODE_NONE && mChoiceMode != CHOICE_MODE_MULTIPLE_CUSTOM) {
        handled = true;/*ww w . j  a  v  a2 s  .com*/
        boolean checkedStateChanged = false;

        if (mChoiceMode == CHOICE_MODE_MULTIPLE
                || (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode != null)) {
            boolean checked = !mCheckStates.get(position, false);
            mCheckStates.put(position, checked);
            if (mCheckedIdStates != null && mAdapter.hasStableIds()) {
                if (checked) {
                    mCheckedIdStates.put(mAdapter.getItemId(position), position);
                } else {
                    mCheckedIdStates.delete(mAdapter.getItemId(position));
                }
            }
            if (checked) {
                mCheckedItemCount++;
            } else {
                mCheckedItemCount--;
            }
            if (mChoiceActionMode != null) {
                mMultiChoiceModeCallback.onItemCheckedStateChanged(mChoiceActionMode, position, id, checked);
                dispatchItemClick = false;
            }
            checkedStateChanged = true;
        } else if (mChoiceMode == CHOICE_MODE_SINGLE) {
            boolean checked = !mCheckStates.get(position, false);
            if (checked) {
                mCheckStates.clear();
                mCheckStates.put(position, true);
                if (mCheckedIdStates != null && mAdapter.hasStableIds()) {
                    mCheckedIdStates.clear();
                    mCheckedIdStates.put(mAdapter.getItemId(position), position);
                }
                mCheckedItemCount = 1;
            } else if (mCheckStates.size() == 0 || !mCheckStates.valueAt(0)) {
                mCheckedItemCount = 0;
            }
            checkedStateChanged = true;
        }

        if (checkedStateChanged) {
            updateOnScreenCheckedViews();
        }
    }

    if (dispatchItemClick) {
        if (mOnItemClickListener != null) {
            playSoundEffect(SoundEffectConstants.CLICK);
            mOnItemClickListener.onItemClick(this, view, position, id);
            if (view != null) {
                view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
            }
            handled = true;
        }
    }

    return handled;
}